Which applications use the getopt "return in order" method?

Quoted from the Linux getopt () page manually :

If the first character of optstring is hyphen( -), then each argv nonoption is treated as if it were an option argument with character code 1. (This is used by programs that have been written to expect options and other argv elements in any order and that care about their ordering.) The special argument double hyphens( --) causes the optional scan to end regardless of the scan mode.

Quoting from the Java GetOpt class man page :

... The second is to allow options anywhere, but return all items in the order they appear on the command line. When an item with no options is canceled, an integer 1 is returned, and the value of the item with no options is stored in optarg if it is an argument to that option. For example, "-a foo -d" returns first "a", then 1 (with optacg set to "foo"), then "d", then -1. When this "back in order" feature is enabled, the only way to stop getopt () from checking all command line items is to use the special "-" line yourself, as described above. For example, "-a foo -b-bar", which returns "a", then an integer 1 with an option set to "foo", then "b", then -1. optind would then point to "bar "as the first non-parallel argv element." - "is discarded.

Yes, I understand what the above statements are talking about, but I still cannot imagine what applications are using this behavior.

Can anyone provide an example of command line syntax that is likely to be used by applications implementing the "return in order" behavior?

+3


source to share


1 answer


find

is an example of a command that mixes parameters and optional arguments and takes care of the order.



+5


source







All Articles