-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Usage errors from clap produce exit status 2 but GNU programs produce exit status 1 #3102
Comments
I think we should ask clap for some customization for this. If they don't want to add something for this, I would suggest that we use |
I have opened clap-rs/clap#3426 on the clap repository. |
All right, that issue was (understandably) a wontfix for them, so we'll have to go with a custom solution. To expand on my previous suggestion, I think we should implement |
I think the feature introduced in pull request #3457 provides a way to solve this problem now. |
It does! We just have to figure out what all the right exit codes are and use that. |
I try to fix all the utils that should return 1 (see below) soon in a PR. I wrote a little script to find all these cases (please excuse my terrible bash skills 😄) for path in src/uu/*; do
util=${path#src/uu/};
env $util --definitely-invalid &> /dev/null
gnu_code=$?
cargo run --features unix -- $util --definitely-invalid &> /dev/null
uutils_code=$?
if [ $gnu_code != $uutils_code ]; then
echo $util;
echo "GNU: $gnu_code";
echo "UUTILS: $uutils_code";
fi
done
Below is some summarized output.
|
This is the same issue I reported previously in #2951, but I noticed that this is a general problem with all programs. The problem is that usage errors that arise from argument parsing (for example, due to conflicting options or missing arguments) in uutils programs cause the process to terminate with exit status 2. But in GNU programs, the process terminates with exit status 1.
For example,
GNU head:
uutils head:
If there is a uniform solution that could be applied to all programs, that would likely help with a lot of test cases in the GNU test suite. For example, there are several test cases in
tests/misc/uniq.pl
that expect exit code 1 where we currently return exit code 2.The text was updated successfully, but these errors were encountered: