Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
howto:getopts_tutorial [2015/02/14 23:18]
ormaaj [Used variables] OPTERR is bash-specific and not POSIX
howto:getopts_tutorial [2015/06/09 22:07] (current)
ogryzek Correct typo: change "an" to "and"
Line 24: Line 24:
 These are all positional parameters, but they can be divided into several logical groups: These are all positional parameters, but they can be divided into several logical groups:
   * ''​-x''​ is an **option** (aka **flag** or **switch**). It consists of a dash (''​-''​) followed by **one** character.   * ''​-x''​ is an **option** (aka **flag** or **switch**). It consists of a dash (''​-''​) followed by **one** character.
-  * ''​-f''​ is also an option, but this option has an associated **option argument** (an argument to the option ''​-f''​):​ ''/​etc/​mybackup.conf''​. The option argument is usually the argument following the option itself, but that isn't mandatory. Joining the option ​an option argument into a single argument ''​-f/​etc/​mybackup.conf''​ is valid.+  * ''​-f''​ is also an option, but this option has an associated **option argument** (an argument to the option ''​-f''​):​ ''/​etc/​mybackup.conf''​. The option argument is usually the argument following the option itself, but that isn't mandatory. Joining the option ​and option argument into a single argument ''​-f/​etc/​mybackup.conf''​ is valid.
   * ''​-r''​ depends on the configuration. In this example, ''​-r''​ doesn'​t take arguments so it's a standalone option like ''​-x''​.   * ''​-r''​ depends on the configuration. In this example, ''​-r''​ doesn'​t take arguments so it's a standalone option like ''​-x''​.
   * ''​./​foo.txt''​ and ''​./​bar.txt''​ are remaining arguments without any associated options. These are often used as **mass-arguments**. For example, the filenames specified for ''​cp(1)'',​ or arguments that don't need an option to be recognized because of the intended behavior of the program. POSIX(r) calls them **operands**.   * ''​./​foo.txt''​ and ''​./​bar.txt''​ are remaining arguments without any associated options. These are often used as **mass-arguments**. For example, the filenames specified for ''​cp(1)'',​ or arguments that don't need an option to be recognized because of the intended behavior of the program. POSIX(r) calls them **operands**.