-
Notifications
You must be signed in to change notification settings - Fork 5
Only sometimes, a late --help
should override other errors
#130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm so confused now... Could you check this behaviour for other utils? My guess is that the option parsing itself goes on to check for help on unrecognized options but that the loop around it doesn't? I think we could emulate it that way, but it'll be tricky. |
Fascinating! I wrote a script to check how each command and option behaves, gathering 159 data points:
I'm happy to share the full results. Here's a screenshot of the partial results: Script so you can run it yourself: test_help.sh.but-for-github-i-renamed-it-to.txt So it seems that GNU du and GNU nl are outliers. Maybe we want to count that as a bug in GNU |
I think I figured something out: $ LC_ALL=C du --banana -B applepie README.md
du: unrecognized option '--banana'
du: invalid -B argument 'applepie'
[$? = 1] So it seems that GNU du tries to report all errors before returning, in contrast to basically all other utils: $ LC_ALL=C df --banana -B applepie README.md
df: unrecognized option '--banana'
Try 'df --help' for more information.
[$? = 1] So I suggest we simply ignore this behavior of GNU du, in favor of consistency. Also, I really hope nobody relies on this weird behavior. |
According to the GNU implementation, arguments should be parsed left-to-right, early errors take precedence, and a later
--help
is IGNORED:At the same time, with the same command, the OPPOSITE is true:
So apparently we should first parse arguments, and raise on errors within recognized options, only then check if
--help
exists, and only then raise on unrecognized options.Insanity!
I'm not sure how to do this best, and I'm afraid this is incompatible with #113.
The text was updated successfully, but these errors were encountered: