Skip to content

Instantly share code, notes, and snippets.

@Frizlab
Created January 19, 2017 16:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Frizlab/19772722fbe713832e3da16d5de3ce91 to your computer and use it in GitHub Desktop.
A bash function to write a given message and retrieve response in named variable
# First argument is the name of the variable in which you want the answer to be.
# Next arguments will compose the message to show to the user before starting
# the reading. An additional space will be added at the end of the message.
print_message_read_response() {
var_name="$1"
eval $var_name=
shift
read -p "$* " $var_name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment