Getopts: Difference between revisions
Appearance
Content deleted Content added
Orphan Wiki (talk | contribs) m Reverted edits by 61.16.182.2 to last revision by Abdull (HG) |
Corrected entry |
||
Line 1: | Line 1: | ||
{{lowercase}} |
{{lowercase}} |
||
'''<code>getopts</code>''' is a |
'''<code>getopts</code>''' is a Unix built-in shell command that programmers can use to process [[command-line argument]]s. It is available in [[Bourne shell]] and [[Bash (Unix shell)]]. |
||
The [[getopts]] built-in command is different from the external program called [[getopt]]. The syntax for using them is totally different. The [[getopts]] command handles whitespaces in argument correctly, whereas the original version of [[getopt]] did not. There is a newer GNU enhanced version of [[getopt]] which can handle whitespaces properly and long option names (which [[getopts]] does not), but it is not available on all systems. |
|||
Typical implementations support complex [[command-line]] patterns. The specification usually allows for long and short parameter names, default values for arguments not provided, and declaration of mandatory versus optional parameters. The command-line arguments are effectively transformed into a data structure or set of data structures which the program can inspect to determine what was requested on the command-line. |
|||
==See also== |
==See also== |
Revision as of 05:19, 29 November 2010
getopts
is a Unix built-in shell command that programmers can use to process command-line arguments. It is available in Bourne shell and Bash (Unix shell).
The getopts built-in command is different from the external program called getopt. The syntax for using them is totally different. The getopts command handles whitespaces in argument correctly, whereas the original version of getopt did not. There is a newer GNU enhanced version of getopt which can handle whitespaces properly and long option names (which getopts does not), but it is not available on all systems.
See also
References
- The Single UNIX Specification, Version 4 from The Open Group : process command line arguments – Shell and Utilities Reference,