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

Return 1 on error? #9

Open
tbm opened this issue Nov 19, 2020 · 3 comments
Open

Return 1 on error? #9

tbm opened this issue Nov 19, 2020 · 3 comments

Comments

@tbm
Copy link

tbm commented Nov 19, 2020

Would it make sense to return 1 is a mistake is found?

anorack t ; echo $?
t:1: a ananas -> an ananas /an'A:n@z/
0
@rjc
Copy link

rjc commented Apr 1, 2022

@tbm I was just about to report the very same issue. Great minds think alike, eh!? ;^)

@jwilk It would be nice to be able to use anorack as part of a Unix pipe from STDIN, i.e. in system manuals:

$ ... | while read man ; do man $man | anorack $man || echo $man ; done

Yes, the above pipeline is a naive one as it ignores manual pages of the same name but from a different sections, i.e. crontab(1) and crontab(5) - it is for demonstration purposes only.

@jwilk
Copy link
Owner

jwilk commented Sep 30, 2022

Well, anorack did its job, so conceptually the exit status 0 sounds right.

I know some other code analysis tools return non-zero when they find something, so if any of you feel strongly about it, I guess I could be presuaded to follow the suit.

Or I could leave the current behavior, and add an option (say -e) to return non-zero if issues are found. Would that work for you?

In the mean time, you can use something like anorack ... | { ! grep ''; }, ideally preceded with set -o pipefail.

@rjc
Copy link

rjc commented Sep 30, 2022

If it's all same to you I'd still vote for option 1 - return non-zero error code if an incorrect article has been found. It doesn't really need to be 1, in case you'd prefer to reserve it for other errors, i.e. runtime.

Alternatively, if you'd rather not change the program's default behaviour, -e would do.

I like the third option the least due to involvement of grep(1) as well as the fact that not all Unix shells support pipefail as it is not part of the POSIX standard... just yet.

jwilk added a commit that referenced this issue Jan 13, 2023
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

3 participants