I figured out through a tutorial that using read -p
would allow me to take the response as a variable. So I did this madlibs kind of thing to test it, hoping that I could repeatedly have user input translated to a variable, then back into output.
Here's an exerpt:
read -p "What is your favorite fruit?" fruit
echo Oh, I see...
sleep 2s
read -p "And what is your mama's name?" mama
echo Amazing...
sleep2s
read -p "And how many years have you been a little bitch?" years
echo Understood...
sleep 2s
echo So let me get this straight...
echo Your favorite fruit is $fruit
echo Your mama's name is $mama
echo And you have been a little bitch for $years years.
Now let's say I answered Apples, Martha, 3. When I do this, my output comes out:
So let me get this straight...
Your favorite fruit is Apples.
Your mama's name is $mama
And you have been a little bitch for $years
Only the first variable is being output properly, the rest isn't. I have tried using different notations for the variables mama and years, changing them for mumuh and yuurs, but no alas.
Is there something obvious I am missing? Am I misunderstanding how the read command handles the created variables?