1
00:00:01,470 --> 00:00:08,460
So in the last lecture who are taking care of positional parameters without any tool but we can use

2
00:00:08,460 --> 00:00:16,140
some tool to help us with argument passing we can use a tool called Get OTS which is really simple but

3
00:00:16,140 --> 00:00:18,390
have also some disadvantages.

4
00:00:18,600 --> 00:00:25,480
Or we can use a tool called Get Up which is really complex but not so easy as Get up.

5
00:00:26,500 --> 00:00:30,550
Okay so in the last lecture we took care of everything.

6
00:00:30,570 --> 00:00:36,630
As you can see right now on the picture if another functionality is needed we would need to write it

7
00:00:36,660 --> 00:00:37,640
by ourself.

8
00:00:37,650 --> 00:00:40,350
For example take a look at this.

9
00:00:40,470 --> 00:00:48,510
Imagine you created your script with positional parameters a and b if user specify parameter a discrete

10
00:00:48,540 --> 00:00:49,470
would print a message.

11
00:00:49,470 --> 00:00:50,130
Hello.

12
00:00:50,220 --> 00:00:54,930
And if user specify parameter b the script would print a message.

13
00:00:54,930 --> 00:00:55,380
Hi.

14
00:00:56,100 --> 00:00:58,960
So now you would see printed hello hi.

15
00:00:59,220 --> 00:01:05,130
But what would happened when someone would run your script with Dash A B and expecting that message

16
00:01:05,130 --> 00:01:13,980
is hell and high would be printed you would need to adjust your script to pass it to dash A and B.

17
00:01:14,060 --> 00:01:25,040
So instead of one argument that a b you needed to pass it as to argument there's a and b this behavior

18
00:01:25,400 --> 00:01:36,360
you can override yourself or for such cases you can use tools like get ups or get up Firstly let us

19
00:01:36,360 --> 00:01:38,180
look on and get ups.

20
00:01:38,280 --> 00:01:45,600
It is a good option for handling short positional parameters but disadvantage is that it cannot handle

21
00:01:45,600 --> 00:01:47,720
a long positional parameters.

22
00:01:47,820 --> 00:01:51,090
So how to use it after a keyboard.

23
00:01:51,090 --> 00:01:59,010
Get opt out of positional parameters followed by string variable which represents positional parameter

24
00:01:59,250 --> 00:02:01,000
which is being processed right now.

25
00:02:01,020 --> 00:02:08,550
For example positional parameter dash a or a positional parameter DHB get opt irritants through.

26
00:02:08,580 --> 00:02:12,770
If some parameter is found it returns false.

27
00:02:12,780 --> 00:02:19,860
If there is no parameter to process this is the reason why we are using get opt in a while loop because

28
00:02:19,950 --> 00:02:27,120
if data is a parameter to process body of while loop will be processed if there is no parameter to process

29
00:02:27,640 --> 00:02:31,060
body available won't be processed.

30
00:02:31,170 --> 00:02:37,990
Now you might asking what does that mean though scones after parameter hay and parameter B.

31
00:02:38,250 --> 00:02:46,350
If you scroll on after some position parameter it is expecting that this parameter is followed by some

32
00:02:46,530 --> 00:02:47,400
argument.

33
00:02:47,700 --> 00:02:54,780
If positional parameter is followed by some argument we can access a value audit argument by using a

34
00:02:54,780 --> 00:02:58,100
variable called Ask.

35
00:02:58,330 --> 00:03:05,740
Here we can see example when running the script with parameter a which argument hell buddy and with

36
00:03:05,770 --> 00:03:12,170
parameters see the end with parameter B with argument car.

37
00:03:12,190 --> 00:03:22,530
You can see that even if we specify the C D get ups handle this as they should chassis and dash the

38
00:03:24,270 --> 00:03:30,570
Believe me get up it is really easy especially when you try to write some script while using and get

39
00:03:30,580 --> 00:03:32,520
opts Get out.

40
00:03:32,550 --> 00:03:35,490
Works with a variable called opt in.

41
00:03:35,910 --> 00:03:43,050
So even though you probably won't use it it is good to know what it is corrupt places index of the next

42
00:03:43,140 --> 00:03:46,170
argument to be processed into this variable.

43
00:03:46,170 --> 00:03:51,110
So at the beginning of your script and value of this variable is equal to 1.

44
00:03:51,180 --> 00:03:54,350
As for argument will be processed.

45
00:03:54,510 --> 00:03:57,310
Now let's talk about get up.

46
00:03:57,480 --> 00:04:02,330
It is more advanced tool and how it looks like in our script.

47
00:04:02,400 --> 00:04:04,890
We are saving into some variable.

48
00:04:04,890 --> 00:04:12,240
In my case into a variable OP's output often get opt command if we want to have short parameters in

49
00:04:12,240 --> 00:04:16,830
our script we specify them after all.

50
00:04:17,610 --> 00:04:25,130
And if we want to use long parameters we specify them after parameter dash dash long shot.

51
00:04:25,140 --> 00:04:31,030
Parameters are next to each other without being divided by some character.

52
00:04:31,050 --> 00:04:40,510
This is same as for a get up to command but long parameters if you need to divide it by comma at the

53
00:04:40,510 --> 00:04:49,370
end of this comment we specify all arguments after this date followed by space we know from get up to

54
00:04:49,370 --> 00:04:57,190
command that if some parameter is followed by column there is a required argument after this parameter.

55
00:04:57,860 --> 00:05:06,920
But here we have two count after a parameter and after file parameter two colons means that parameter

56
00:05:06,950 --> 00:05:10,160
can be followed by optional parameter.

57
00:05:10,160 --> 00:05:11,620
We can provide it or not.

58
00:05:11,660 --> 00:05:18,800
It is up to us but it's a little tricky when do we want to use optional argument after a short positional

59
00:05:18,800 --> 00:05:19,790
parameter.

60
00:05:19,790 --> 00:05:24,710
If you need to write that argument right after parameter without any space.

61
00:05:24,710 --> 00:05:31,190
And if we want to use it after a long positional parameter we need to write it right after parameter

62
00:05:31,220 --> 00:05:40,220
followed by equal sign when all positional parameters are specified using ever set command.

63
00:05:40,450 --> 00:05:42,530
We bar script arguments.

64
00:05:42,730 --> 00:05:49,990
So if we do a little change in a script on the beginning I am going to print all arguments and the same.

65
00:05:49,990 --> 00:05:53,170
I will do at the end of the script.

66
00:05:53,170 --> 00:06:04,640
We can now see how it behaves I have run script with Dash C D E dash a followed by this is optional

67
00:06:05,330 --> 00:06:16,670
dash B parameter wait argument called required devilish filed it optional argument called optional dash

68
00:06:16,670 --> 00:06:24,600
dash named parameter with argument called required and with parameter dash does help on the first line.

69
00:06:24,620 --> 00:06:29,180
We can see all arguments we pass into script on the next line.

70
00:06:29,270 --> 00:06:32,450
We can see past arguments after being processed by.

71
00:06:32,480 --> 00:06:32,980
Get up.

72
00:06:32,990 --> 00:06:33,500
Come on.

73
00:06:34,250 --> 00:06:36,260
So you can see that dish.

74
00:06:36,290 --> 00:06:45,020
See the E is passed as dash C D D D E so instead of one argument dash see the e..

75
00:06:45,140 --> 00:06:55,640
We now have three arguments mesh c d d And Dash E and you can for example see that devilish file equals

76
00:06:55,650 --> 00:07:01,920
sign optional was passed as digit ish file space option.

77
00:07:02,010 --> 00:07:10,500
Now if you have past scripts arguments we can process them in the same vein how we already did it using

78
00:07:10,500 --> 00:07:17,970
a while loop to loop all arguments and processing it one by one so thoroughly lecture is done.

79
00:07:18,120 --> 00:07:24,080
It might be hard to understand now but believe me once you tried you will find it easy.
