What and how is the relation between the if statement in MAIN_MENU function and the case statements.
When MAIN_MENU()
is invoked for the first time, the if
condition is false and the function reads user input.
If the input matches one of the first three cases, the corresponding function is invoked.
If the input is anything else (i.e. the asterisk denotes any character), then the MAIN_MENU()
function is invoked again, but also has the argument “Please enter a valid option.” passed to it.
This means that this time the if
condition is triggered, which then prints that message before again requesting user input.
Ok, got the logic here
Can you tell me what does the ‘$1’ mean there?
Have you completed the other Relational Database courses prior to this one?
Passing arguments to scripts/functions is covered first in Learn Bash Scripting by Building Five Programs and then crops up again in various other places after that.
Essentially, $1
denotes the first argument passed to a script (as $2
denotes the second etc). So the condition if [[ $1 ]]
simply asks ‘has an argument been passed to this’?
Ohh ohk now I got this, I’ve completed them but was not able to relate properly.
thanks for your help.