How can I pass a variable name to a function and use it outside its scope?
I tried this but it doesn't work:
questionPrompt() {
while [ -z "$answer" ]; do
echo $1
read answer
${2}=$answer
done
}
questionPrompt "Which color do you like?" "COLOR"
echo $COLOR
It says: COLOR=red: command not found