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

Incorrect exit status when there are 256 (or more) problematic files #70

Closed
JaapJoris opened this issue Jan 30, 2023 · 0 comments
Closed
Assignees

Comments

@JaapJoris
Copy link
Member

The README states the following:

If any errors were encountered, the exit status indicate[s] the number of problematic files. However, when the option -c / --check is used, the exit status is the number of files that would have changed, but no changes are actually made.

The actual statement responsible for this can be found here:

sys.exit(changed_files if args.check else problematic_files)

While this seems clever, it's actually an antipattern because, in POSIX, the exit status cannot be greater than 255. When the number of problematic files is 256, the exit status will wrap around and actually become 0 again, indicating success rather than failure. This is particularly nasty for scripts that check exit status, because once in blue moon they will function incorrectly and most likely leave their authors puzzled as to why.

To fix it, let's make the exit status always 1 or 0 and nothing else.

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

No branches or pull requests

1 participant