Documentation

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

truegetopt function errors are displayed.
falsegetopt 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

trueSets optind to 1; the next call to getopt(), getoptlong(), or getopt_long_only() starts from the beginning of the argv list.
falsegetopt 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

trueAllows getopt_long()'s strict interpretation of argument parameters. The default is true.
falseMakes getopt_long() recognize --argument parameter specifications.

Example

optstrictparameters = false;

Example

optstrictparameters = false;

©2003-2025 BeyondTrust Corporation. All Rights Reserved. Other trademarks identified on this page are owned by their respective owners. BeyondTrust is not a chartered bank or trust company, or depository institution. It is not authorized to accept deposits or trust accounts and is not licensed or regulated by any state or federal banking authority.