oz4546/Scripts1

"break" statement is inside the function

Opened this issue · 1 comments

The "break" part should always be a part of the loop (while loop in your case).

change it to the following:
if the user input is valid, return the value "0" with - return 0
if the user input is invalid, return the value "1" with - return 1

in the loop, check the function's return value (with $?) and don't break until it is 0.

Even better - change your input validation functions, and create one function called "decision"

the function will get 2 arguments (Y or N, 1 or 2, etc.)
It will check that the user input matches the options available (i.e. if the user input is either $1 or $2), and will return 1 or 2 accordingly.