I'm using GNU bash, version 4.3.46 on a Ubuntu machine. For some reason this while loop doesn't work as expected.
The menu should loop continuously until the user decides to quit the program, then there is some error checking prompting the user if they are sure, then the program ends.
Here's the code:
#!/bin/bash menu_choice=0 quit_program="n" while [[ $menu_choice -ne 3 && $quit_program != "y" ]] do printf "1. Backup\n" printf "2. Display\n" printf "3. Exit\n\n" printf "Enter choice: \n" read menu_choice if [ $menu_choice -eq 3 ] then printf "Are you sure you want to quit? (y/n)\n" read quit_program fi done
I think it might have to with global variables are declared at the beginning and I'm reading in a new value locally...