Can someone explain me this code

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.

1 Like

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.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.