Command line parsing variables
These variables support the getopt(), getopt_long(), and getopt_long_only() policy language functions. These functions examine the read-only task information variable env.
optarg
Data type
Integer, read-only
Description
Used with getopt functions. Contains the parameter for the last argument or an empty string if none was found.
Valid values
A positive integer.
Example
if (option == "f") filename = optarg;
opterr
Data type
Boolean
Description
Used with the getopt functions. Determines whether to display errors from these functions.
Valid values
true | getopt function errors are displayed. |
false | getopt function errors are not displayed. |
Example
if (opterr == false) accept;
optind
Data type
Integer
Description
Used with getopt functions. Contains the current argument list index.
Syntax
optind = integer;
Valid values
An integer between 0 and argc.
Example
if (optind < argc) accept;
optopt
Data type
String, read-only
Description
Used with getopt functions. Contains the letter of the last option that had a problem.
Valid values
A string.
Example
if (error) print ("Bad option", optopt);
optreset
Data type
Boolean
Description
Used with getopt functions. Set this to true to restart the getopt functions from the start. The next time a getopt function is called, optind is set to 1.
Syntax
optreset = boolean;
Valid values
true | Sets optind to 1; the next call to getopt(), getoptlong(), or getopt_long_only() starts from the beginning of the argv list. |
false | getopt functions are not restarted from the beginning of the argv list. |
example
optreset = true;
optstrictparameters
Data type
Boolean
Description
The getopt_long() function provides strict interpretation of argument parameters. In particular, arguments with optional parameters are accepted only in the form --argument=parameter.
Some non-compliant programs allow --argument parameter. To make getopt_long() recognize the latter form, set optstrictparameters to false.
Syntax
optstrictparameters = boolean;
Valid values
true | Allows getopt_long()'s strict interpretation of argument parameters. The default is true. |
false | Makes getopt_long() recognize --argument parameter specifications. |
Example
optstrictparameters = false;
Example
optstrictparameters = false;
Updated 5 days ago