-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
umpf: answer interactive prompts with default when --default set #50
base: master
Are you sure you want to change the base?
Conversation
I think a |
Ok, but doesn't it make sense to have piping yes behave as expected as well? |
Fair point. I would rename the option then though. How about |
Sounds good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few, mostly cosmetic things left.
else | ||
read -e -i "$def" -p "$prompt: " choice | ||
fi | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use ${...}
for all variables. We're not fully consistent overall, but it used in most cases.
And choice
schould be a local variable.
Same everywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
choice is intentionally not local, so it can be used outside the function. I am not good enough at bash to make it work with a local, can you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, I put that comment in the wrong place. It should be local in the calling function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding was that choice as written by read_interactive is a global variable, so the callers need to access to choice
global variable. I need to try out whether it still works with local in the calling function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A local variable in bash is valid until the end of the function, including all functions that are called within that function.
When building or tagging an umpf, umpf can ask which branch to use when multiple are available. Piping yes(1) into umpf in this case doesn't work, because the variable populated by read in that case is left empty. Provide for this use case, a --default option that will take a default if one is known. Signed-off-by: Ahmad Fatoum <[email protected]>
When building or tagging an umpf, umpf can ask which branch to use when multiple are available. Piping
yes(1)
into umpf in this case doesn't work, because the variable populated by read in that case is left empty.Handle this case to reduce user confusion.