1
00:00:00,940 --> 00:00:04,850
In this lecture we will play with challenging get optical month.

2
00:00:05,200 --> 00:00:10,080
Great script called Get off the stage and start with Shaban

3
00:00:14,250 --> 00:00:15,110
from the beginning.

4
00:00:15,110 --> 00:00:24,960
We can print all arguments given to our script do not assign it represents all arguments.

5
00:00:25,800 --> 00:00:33,510
Now we into of the variable output of get optical month where we will have some short positional parameters.

6
00:00:33,750 --> 00:00:40,650
So we need to use and dash 0 followed by let's say parameter a which will have optional argument and

7
00:00:40,680 --> 00:00:47,280
if it is optional we need to provide two columns parameter B must have some argument that's why we want

8
00:00:47,270 --> 00:00:53,160
to call on and parameters see the e won't have any arguments that's why we don't specify any call on

9
00:00:53,250 --> 00:00:55,440
after them now right.

10
00:00:55,450 --> 00:01:01,590
Dash dash long for the long parameters and there we will have parameter file with optional argument

11
00:01:01,860 --> 00:01:10,590
parameter name with the required argument and parameter a help without any argument at the end of forget

12
00:01:10,680 --> 00:01:18,110
command we need to specify arguments which are going to be passed so degradation space dollar sign and

13
00:01:19,530 --> 00:01:27,630
by ls set command we are changing initial arguments and for being sure the change really happened we

14
00:01:27,630 --> 00:01:32,700
can print all arguments after they were passed would get up to command

15
00:01:43,740 --> 00:01:52,680
so just to recap how get opt works and get up command returns past arguments in order to pass them we

16
00:01:52,680 --> 00:02:00,390
need to specify to get opt command what parameters we are taking into account if we are specifying short

17
00:02:00,390 --> 00:02:08,220
parameters that means parameters starting with dash for example dash a we need to specify them after

18
00:02:08,250 --> 00:02:09,650
this all parameter.

19
00:02:10,800 --> 00:02:18,450
So here we have parameter a followed by two columns which means that parameter 8 can be followed by

20
00:02:18,480 --> 00:02:27,180
optional argument then we have parameter B with column that means with required argument then we have

21
00:02:27,180 --> 00:02:37,080
parameters c d and e which don't take any arguments Evie in our script want to have long parameters

22
00:02:37,230 --> 00:02:46,100
as for example designated file we need to specify them after David's long parameter of course we need

23
00:02:46,100 --> 00:02:53,740
to tell to get up to command what arguments we want to pass and we can do that by using digital age

24
00:02:53,810 --> 00:02:55,940
space the latter sign at

25
00:02:59,330 --> 00:03:07,910
So now we'll do the same we did with our script file check it as if we need to process pass arguments

26
00:03:08,810 --> 00:03:15,740
one by one so while number of arguments is greater than zero 0 exit could do better inside while loop

27
00:03:17,360 --> 00:03:27,440
if first argument is a we can print barometer a selected

28
00:03:31,440 --> 00:03:39,180
so if we choose def a if if A is first argument print parameter a

29
00:03:43,160 --> 00:03:50,680
selected with argument dollar assigned to.

30
00:03:50,930 --> 00:03:56,340
Now we need to get rid of parameter and argument by to shift commands

31
00:04:02,490 --> 00:04:10,920
or we can just override shift tool it does the same thing as to shift commands

32
00:04:14,080 --> 00:04:17,360
for option B and we will bring something similar.

33
00:04:17,380 --> 00:04:18,400
So just copy.

34
00:04:18,400 --> 00:04:20,380
Option A and edit it

35
00:04:36,070 --> 00:04:41,020
for Option C we will print Option C selected

36
00:04:45,210 --> 00:04:52,960
or parameters c selected and we will get rid of this parameter by shift command.

37
00:04:55,080 --> 00:04:56,600
No need for another shift command.

38
00:04:56,640 --> 00:04:59,730
As if it didn't specify column after this parameter.

39
00:04:59,730 --> 00:05:02,920
So no argument is expected here.

40
00:05:02,970 --> 00:05:10,830
Option D and E will be pretty much the same so just copy Option C and edit it.

41
00:05:23,290 --> 00:05:34,370
In case long option parameter a file was used we will print parameter file selected wait

42
00:05:36,860 --> 00:05:37,480
argument

43
00:05:41,010 --> 00:05:47,140
dollar assigned to our assigned to represent that argument that date value of the argument.

44
00:05:47,900 --> 00:05:51,570
And of course she could do to get rid of arguments.

45
00:05:51,590 --> 00:05:54,560
An optional argument.

46
00:05:54,690 --> 00:06:01,570
Sorry I said you only to get rid of parameters and optional argument in case no argument was selected

47
00:06:01,660 --> 00:06:07,220
as it is optional though are assigned to will be an empty string the same.

48
00:06:07,240 --> 00:06:10,150
Of course we can do for name parameter

49
00:06:19,690 --> 00:06:24,080
shift too and we have.

50
00:06:24,100 --> 00:06:31,390
But I mean the help so for parameter help we can print parameter to help selected

51
00:06:35,300 --> 00:06:40,220
and there is no argument so just only one shift.

52
00:06:44,050 --> 00:06:47,230
And for cases something else was selected

53
00:06:52,490 --> 00:07:05,260
we can just posit that option of a puzzle does pass that argument and it's all we can now say with the

54
00:07:05,270 --> 00:07:06,090
script.

55
00:07:11,670 --> 00:07:13,370
Ground execute permissions

56
00:07:16,140 --> 00:07:17,090
and we can run it.

57
00:07:18,390 --> 00:07:20,810
Firstly drive it Dash CDE

58
00:07:29,140 --> 00:07:42,490
and we see that it transform this city into dash C dash D and dash e gate.

59
00:07:42,540 --> 00:07:53,910
Now we can do some little change we can add parameter a followed by optional argument without any space.

60
00:07:55,760 --> 00:08:00,490
And an optional argument is called optional in my case.

61
00:08:00,490 --> 00:08:01,710
And we see that.

62
00:08:01,780 --> 00:08:02,460
Get up.

63
00:08:02,470 --> 00:08:08,470
Pass it to dash a and optional argument which is great.

64
00:08:08,500 --> 00:08:09,040
It works.

65
00:08:11,580 --> 00:08:15,170
If you don't specify arguments for parameter a.

66
00:08:16,050 --> 00:08:24,070
We see that parameter a was selected with non existing argument.

67
00:08:24,090 --> 00:08:26,630
Now let's say at option B

68
00:08:29,490 --> 00:08:33,730
followed by argument call required.

69
00:08:33,750 --> 00:08:41,610
Because in Get up come on to B wrote one column after parameter B and the long option file followed

70
00:08:41,610 --> 00:08:53,930
by equal sign optional and add also long option name parameter with argument required.

71
00:08:55,970 --> 00:08:58,640
And we see that it was part as well

72
00:09:01,630 --> 00:09:13,030
in case that we didn't specify required argument it can be for example for a parameter name we got at

73
00:09:13,030 --> 00:09:17,760
or from get opt command option name requires an argument.

74
00:09:19,530 --> 00:09:29,350
Now if we didn't specify optional argument for a parameter file we see that parameter file was selected

75
00:09:29,360 --> 00:09:30,920
with no argument.

76
00:09:30,920 --> 00:09:39,530
Great but what happens if the after parameter a file put a value something of value something wasn't

77
00:09:39,530 --> 00:09:45,320
kept as file parameter needs equal sign of an optional argument is given.

78
00:09:45,320 --> 00:09:56,050
If we go back to the script we can change it a little bit we will edit section for case something else

79
00:09:56,050 --> 00:10:18,580
was given as an argument and we will write what was given what argument was given.

80
00:10:19,160 --> 00:10:27,510
Now around the script again and we see that we are printing two dashes which marks the end of arguments

81
00:10:27,510 --> 00:10:35,560
passed by get up and then we see something which is argument which wasn't which wasn't passed by.

82
00:10:35,650 --> 00:10:39,760
Up and Get Up but part can be really challenging.

83
00:10:39,930 --> 00:10:46,080
It has own rules which needs to be followed but if you play with it more you will get used to it.

84
00:10:46,860 --> 00:10:50,870
Now it's up to you and the situation what method to choose.

85
00:10:50,910 --> 00:10:58,800
You can take care of scripts arguments yourself as we did for file check script or you can use quite

86
00:10:58,860 --> 00:11:06,330
easy get opt which has the limitation of not processing along parameters or you can use more advanced

87
00:11:06,660 --> 00:11:07,140
get opt.
