Closed masics closed 6 years ago
Believe it or not, this is actually intentional behavior.
The motivation for this behavior is that you could create a wrapper scripts that supplied the option. eg:
#!/bin/bash
# autumn-script.sh
./script --config /usr/lib/script/autumn.config "$@"
and:
#!/bin/bash
# winter-script.sh
./script --config /usr/lib/script/winter.config "$@"
Now invoking autumn-script.sh or winter-script.sh will report --config as being optional.
I admit that this behavior is somewhat surprising. My assumption was that it would be pretty rare that a user would supply other options in addition to --help
, except in the case where they were using a wrapper script that passed through options like the above examples.
Assume you have following configuration:
Invoking command like
script --config filename --help
will print:As you can see "--config" is under optional arguments. It must be under mandatory ones.
If you execute:
script --help
The result is correct (config is under required):