Hi!
I was think about creating an interactive script and output the result
to a variable like this:
=========================
function ask_question() {
printf "$1"
read ANSWER
printf "Answer: $ANSWER\n"
}
the_answer=$(ask_question "Are you happy?")
printf "$the_answer"
=========================
This obviously does not work.
Do I need to use a global variable in such a case, or are there better options?
With global:
=========================
function ask_question() {
printf "$1"
read ANSWER
}
ask_question "Are you happy?"
the_answer=$ANSWER
ANSWER=""
printf "Answer: $the_answer\n"
=========================
Thanks for input!
Richard Taubo