Package: glib

Function g-option-context-strict-posix

Lambda List

g-option-context-strict-posix (context)

Arguments

context -- a g-option-context instance
strict -- true if strict POSIX is enabled, false otherwise

Details

The g-option-context-strict-posix function returns whether strict POSIX code is enabled. The (setf g-option-context-strict-posix) function sets strict POSIX mode. By default, this mode is disabled.

In strict POSIX mode, the first non-argument parameter encountered, e.g. filename, terminates argument processing. Remaining arguments are treated as non-options and are not attempted to be parsed.

If strict POSIX mode is disabled then parsing is done in the GNU way where option arguments can be freely mixed with non-options.

As an example, consider ls foo -l. With GNU style parsing, this will list foo in long mode. In strict POSIX style, this will list the files named foo and -l.

It may be useful to force strict POSIX mode when creating "verb style" command line tools. For example, the gsettings command line tool supports the global option --schemadir as well as many subcommands, get, set, etc., which each have their own set of arguments. Using strict POSIX mode will allow parsing the global options up to the verb name while leaving the remaining options to be parsed by the relevant subcommand, which can be determined by examining the verb name, which should be present in the second command line argument after parsing.
 

See also

2021-9-18