bash script question
Linux for blind general discussion
blinux-list at redhat.com
Mon Dec 12 01:12:38 UTC 2022
Hi,
I have a question about bash scripting.
Can someone point me in the right direction?
I want the script to loop until the correct response is given, but I cant get it to work. see code below.
#!/bin/bash
quiz() {
echo "Starting quiz..."
echo "What is 2+2?"
read response
if [ "$response" == 4 ]
then
echo "You got it."
else
echo "That is incorrect."
until [ "$response" == 4 ]; do
fi
echo "Begin math quiz? (y/n)"
read response
if [ "$response" == "y" ] || [ "$response" == "Y" ]
then
SECONDS=0
quiz
echo "The quiz took you $SECONDS seconds to complete."
else
echo "Exiting..."
fi
More information about the Blinux-list
mailing list