vendredi 26 mars 2021

How to Properly Set Up If in While Loop

I'm going to add the rest of the functionality to the program later it's still in it's early stages, but I cant seem to get out of the while loop for some reason even though the if statement is within it and under the menu. Here's the code so far.

continue="true"

#while loop to keep the code running till the user inputs Q
while [ $continue = "true" ] 

#loop start
do
        #clearing screen before showing the menu
        clear
        echo "A to Create a user account"
        echo "B to Delete a user account"
        echo "C to Change Supplementary Group for a user account"
        echo "D to Create a user account"
        echo "E to Delete a user account"
        echo "F to Change Supplementary Group for a user account"
        echo "Q to Quit"
        read -p "What would you like to do?:" choice

        #Test to end the program
        if [ $choice = 'Q' ] || [ $choice = 'q']
                then
                $continue="false"
        fi
#loop end
done```

Aucun commentaire:

Enregistrer un commentaire