mbiti2 / Student-s_projects

This project is arned at creating an algorithm to select students for the LPI exams.
0 stars 2 forks source link

Script exits when i type a letter different from y or n #3

Open Motouom opened 2 weeks ago

Motouom commented 2 weeks ago
while true
do
 read -p "Do you want to continue : " yeah
 if [ "$yeah" = "y" ]; then
    welcome ; accept_student
else
    echo "thanks for using this app"
    break
 fi

When i type something aprt from y, the script exits automatically. That should not be the case. Instead, i should get an error message telling me to press y to continue or n to exit. Some thing like this

while true
do
    read -p "Do you want to continue (y/n): " yeah
    if [ "$yeah" = "y" ]; then
        welcome
        accept_student
    elif [ "$yeah" = "n" ]; then
        echo "Thanks for using this app."
        break
    else
        echo "Please type either 'y' to continue or 'n' to exit."
    fi
done