2.2 Aliases for Options and Environment Variables

The fields long_opt, subopt_name, and env_var of the MU_OPT structure (see Option Structure) allow aliases separated by ‘|’. The short_opt field allows aliases to be specified as multiple characters in the string (which must be terminated by a null byte).

For example, the string ‘abc’, when specified as the short_opt field, indicates three equivalent short options: -a, -b, and -c. In the long_opt field, ‘foo|bar|baz’ would specify three equivalent long options: --foo, --bar, and --baz. The same goes for subopt_name and env_var (but see Parsing the Environment for more information on environment variable aliases).

Duplicate aliases are not allowed, and will be diagnosed as an error. For example, in the short_opt field, ‘abcb’ will be diagnosed because the ‘b’ is repeated. Likewise, ‘foo|bar|foo’ would be diagnosed in any of the long_option, subopt_name, or env_var fields. Empty aliases are diagnosed as well (including the entire string being empty). So ‘foo||bar’ would be diagnosed in any of the long_option, subopt_name, or env_var fields, because there is an empty alias between ‘foo’ and ‘bar’. In any of the same fields, in addition to short_opt, the empty string (‘’) will be diagnosed as well. Leave a field as NULL if you don’t want any options (or environment variables) of that type.