|
|
|
|
|
by em500
2566 days ago
|
|
clear
echo "Hello there. I'm a computer. What's your name?"
read G
echo "Hello $G. You are welcome to computer land."
while true
do
echo ""
echo "What would you like to do today?"
echo "1) Say something random"
echo "2) Make a maze"
echo "3) Exit"
echo "Enter your selection"
read S
if [ "$S" = "1" ]; then
say $( head -n $((7*RANDOM)) /usr/share/dict/words | tail -n 1 )
elif [ "$S" = "2" ]; then
for i in {1..3000}; do
if (($RANDOM>16384)); then printf '/'; else printf '\'; fi
done
elif [ "$S" = "3" ]; then
echo "Bye."
exit
else
echo "Try again."
fi
done
This doesn't seem much different than the BASIC example to me. I think only the lack of GOTO in shell scripts makes this look slightly more complicated (requiring either putting all the statements in the if ... elif parts or defining functions).I honestly don't see how a Python or Ruby version would be much better than a shell version for this. Perhaps you can show by example? |
|
I still contend that Ruby and Python are far more accessible than shell scripting, because they are very popular, especially Python, cross-platform, and less arcane.