In this lecture started with grating script called Get up it's not an age where we will practice handling
of positional parameters.
Let's say that you want parameters A and B with some arguments and parameters c and d without no arguments
without any arguments.
So we need to put call on after a and after B to tell get out that arguments are needed here.
So why get up to command will be through all screwed we'll be executing body of while loop so one time
more after a get up to command.
We are placing positional parameters as parameters A and B require argument.
We need to specify gone after them.
So we see a go on B equal on CB.
After a C or after D.
There is no call on that means that those positional parameters don't need any argument body of a while
loop will be executed when output of a get opts command is through.
That means of an output often get opts command has exit status zero and then all positional parameters
are processed exit status of get up to command is non-zero.
And that means that body of available want won't be processed.
Now we need to ask what is the current parameter to process.
We will check it with case statement
in case the parameter to process is parameter a visual print parameter a barometer
a weight argument
dollar sign up tag
of Arc is variable which has the value of required argument.
Note that the way to get out we didn't check for a parameter starting with the dash get off it handle
this automatically.
So here we didn't check for a positional parameter a dash a but only for a In case B was selected.
We'll print parameter B
parameter B
selected with argument which has value of variable arc
okay.
So in the case Siebel selected we can just print that parameter C was selected.
That is not nothing more
so parameter C selected here remember that we did a news column after parameter C so there is no argument
expected and we can do the same for the parameter.
The
so echo parameter be selected
now the script is done.
We have set what should be done in case specific parameter is selected.
So now the tricky question.
Have you noticed that in the script we are not using keyboard shift for moving away arguments.
We don't need to do that.
Get out in the background has note how many positional parameters of error process and for that specific
reason.
Get ups uses opt in variable we discussed in Del lecture.
This is if I get up it is so easy we don't need to take care of shifting argument if a or is handled
by get opt.
We only need to specify parameters and say what to do when those parameters vary.
Used
we can now just save and exit the script
ground exit permissions
and we can handle it.
Let's say with parameter a wait um argument call required
with parameter B with argument also required and with Dash C D which means both parameters see.
So you'll see that even we put def S.D. it passes both parameters as if we use the C and dash D gate.
Now let's play a little more I can add another a parameter without any argument and we see error message
option requires an argument.
Great now we can both dash DC as a first parameters
and if you hit on it it disperses without any issue you can now play with positional parameters yourself
and I will wait for you in the next lecture.