DESCRIPTION top. The getopt () function parses the command-line arguments. Its arguments argc and argv are the argument count and array as passed to the main () function on program invocation. An element of argv that starts with '-' (and is not exactly "-" or "--") is an option element. The characters of this element (aside from the initial. The getopt function incrementally parses a command line argument list argv and returns the next known option character. An option character is known if it has been specified in the string of accepted option characters, optstring. The option string optstring may contain the following elements: individual characters, and characters followed by a colon to indicate an option . · Description. getopts is the bash version of another system tool, www.doorway.ru that the bash command has an s at the end, to differentiate it from the system command.. While the getopt system tool can vary from system to system, bash getopts is defined by the POSIX standard. So if you write a script using getopts, you can be sure that it runs on any system .
While the getopt system tool can vary from system to system, bash getopts is defined by the POSIX standard. So if you write a script using getopts, you can be sure that it runs on any system running bash in POSIX mode (e.g., set-o posix). getopts parses short options, which are a single dash ("-") and a letter or digit. The getopts utility can be used to retrieve options and arguments from a list of arguments specified by args or the positional parameters if arg is omitted. It can also generate usage messages and a manual page for the command based on the information in optstring. Each time it is invoked, the getopts utility places the value of the next. The getopt () function parses the command-line arguments. Its arguments argc and argv are the argument count and array as passed to the main () function on program invocation. An element of argv that starts with '-' (and is not exactly "-" or "--") is an option element. The characters of this element (aside from the initial '-') are option.
1 de fev. de On Unix-like operating systems, getopts is a builtin command of the Bash shell. It parses command options and arguments, such as those. GETOPT(3) NetBSD Library Functions Manual GETOPT(3) NAME getopt -- get option character from command line argument list. LIBRARY Standard C Library (libc. GETOPT(1) FreeBSD General Commands Manual GETOPT(1) NAME getopt -- parse command options SYNOPSIS args=`getopt optstring $*` ; errcode=$?;.
0コメント