Skip to content
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

[#21] Use exit(1) as exit status code when printing Usage: [...] #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

iperdomo
Copy link

  • If su-exec is used as part of an environment where exit codes are
    used to signal errors. We can consider using wrong number of
    arguments as an error, then we can use exit(1) for that.

- If su-exec is used as part of an environment where exit codes are
  used to signal errors. We can consider using wrong number of
  arguments as an error, then we can use exit(1) for that.
@jakirkham
Copy link

jakirkham commented Jun 22, 2018

Could we at least allow a -h/--help option that doesn't fail then?

Edit: Also -v/--version would be nice to have not failing too.

@iperdomo
Copy link
Author

@jakirkham in this case the print of Usage is because the number of arguments is wrong argc < 3 so I guess you're requesting a new feature. TBH I don't know if this PR will be merged, it was just my proposal for fixing a problem I faced.

su-exec.c Outdated
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])

argv0 = argv[0];
if (argc < 3)
usage(0);
usage(1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to /usr/include/sysexits.h (Linux) / man 3 sysexits (*BSD), shouldn't we return 64 (EX_USAGE) here, to comply with POSIX standard?

EX_USAGE -- The command was used incorrectly, e.g., with the wrong number of arguments, a bad flag, a bad syntax in a parameter, or whatever.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelbaudino thanks for the review. I'll update the PR

Based on a review by @michaelbaudino

> According to /usr/include/sysexits.h (Linux) / man 3 sysexits
> (*BSD), shouldn't we return 64 (EX_USAGE) here, to comply with POSIX
> standard?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants