So in the last lecture who are taking care of positional parameters without any tool but we can use
some tool to help us with argument passing we can use a tool called Get OTS which is really simple but
have also some disadvantages.
Or we can use a tool called Get Up which is really complex but not so easy as Get up.
Okay so in the last lecture we took care of everything.
As you can see right now on the picture if another functionality is needed we would need to write it
by ourself.
For example take a look at this.
Imagine you created your script with positional parameters a and b if user specify parameter a discrete
would print a message.
Hello.
And if user specify parameter b the script would print a message.
Hi.
So now you would see printed hello hi.
But what would happened when someone would run your script with Dash A B and expecting that message
is hell and high would be printed you would need to adjust your script to pass it to dash A and B.
So instead of one argument that a b you needed to pass it as to argument there's a and b this behavior
you can override yourself or for such cases you can use tools like get ups or get up Firstly let us
look on and get ups.
It is a good option for handling short positional parameters but disadvantage is that it cannot handle
a long positional parameters.
So how to use it after a keyboard.
Get opt out of positional parameters followed by string variable which represents positional parameter
which is being processed right now.
For example positional parameter dash a or a positional parameter DHB get opt irritants through.
If some parameter is found it returns false.
If there is no parameter to process this is the reason why we are using get opt in a while loop because
if data is a parameter to process body of while loop will be processed if there is no parameter to process
body available won't be processed.
Now you might asking what does that mean though scones after parameter hay and parameter B.
If you scroll on after some position parameter it is expecting that this parameter is followed by some
argument.
If positional parameter is followed by some argument we can access a value audit argument by using a
variable called Ask.
Here we can see example when running the script with parameter a which argument hell buddy and with
parameters see the end with parameter B with argument car.
You can see that even if we specify the C D get ups handle this as they should chassis and dash the
Believe me get up it is really easy especially when you try to write some script while using and get
opts Get out.
Works with a variable called opt in.
So even though you probably won't use it it is good to know what it is corrupt places index of the next
argument to be processed into this variable.
So at the beginning of your script and value of this variable is equal to 1.
As for argument will be processed.
Now let's talk about get up.
It is more advanced tool and how it looks like in our script.
We are saving into some variable.
In my case into a variable OP's output often get opt command if we want to have short parameters in
our script we specify them after all.
And if we want to use long parameters we specify them after parameter dash dash long shot.
Parameters are next to each other without being divided by some character.
This is same as for a get up to command but long parameters if you need to divide it by comma at the
end of this comment we specify all arguments after this date followed by space we know from get up to
command that if some parameter is followed by column there is a required argument after this parameter.
But here we have two count after a parameter and after file parameter two colons means that parameter
can be followed by optional parameter.
We can provide it or not.
It is up to us but it's a little tricky when do we want to use optional argument after a short positional
parameter.
If you need to write that argument right after parameter without any space.
And if we want to use it after a long positional parameter we need to write it right after parameter
followed by equal sign when all positional parameters are specified using ever set command.
We bar script arguments.
So if we do a little change in a script on the beginning I am going to print all arguments and the same.
I will do at the end of the script.
We can now see how it behaves I have run script with Dash C D E dash a followed by this is optional
dash B parameter wait argument called required devilish filed it optional argument called optional dash
dash named parameter with argument called required and with parameter dash does help on the first line.
We can see all arguments we pass into script on the next line.
We can see past arguments after being processed by.
Get up.
Come on.
So you can see that dish.
See the E is passed as dash C D D D E so instead of one argument dash see the e..
We now have three arguments mesh c d d And Dash E and you can for example see that devilish file equals
sign optional was passed as digit ish file space option.
Now if you have past scripts arguments we can process them in the same vein how we already did it using
a while loop to loop all arguments and processing it one by one so thoroughly lecture is done.
It might be hard to understand now but believe me once you tried you will find it easy.