[Toybox] Command exit numbers.
enh
enh at google.com
Mon Jun 12 08:49:28 PDT 2017
On Sat, Jun 10, 2017 at 11:29 AM, Rob Landley <rob at landley.net> wrote:
> Would it be useful if perror_exit() set exitval to errno by default
> instead of 1? They're well defined values that let you know _what_ happened.
...except the caller doesn't know whether it's looking at an errno
value. and what could a caller realistically do anyway? it's bad
enough working out what exactly EINVAL means if the last thing you did
was call mmap, but if you just ran toybox... that failure could be
coming from anywhere.
> I just fixed grep so it doesn't error_exit() when it hits a dangling
> symlink (because fdopen() failed to covert fd to file *), but
> perror_msg() sets errno to 1, and "grep -rq blah" has 1 mean "didn't
> find what we were grepping for". In this instance, finding it stops and
> returns 0 immediately so if you hit one of those it won't change the
> results, but the caller can't distinguish "did not find" from "hit
> dangling symlink and wanted to report it as an error" unless they
> capture stderr. In this case that's probably fine, but it made me think
> about the more general problem.
isn't grep a well-known special case?
"if any error occurs and -q is not given, the exit status is 2."
> The downside would be other commands that use error return values other
> than 0 and 1 already. This could create false positives for that.
i've certainly seen scripts explicitly check for 0 and 1 exit statuses.
> *shrug* Thought I'd ask. I still have this annoying cold and trying to
> think through it myself right now isn't getting a lot of traction.
seems to me like it would break a lot of expectations, while not being
obviously usable?
> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net
--
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.
More information about the Toybox
mailing list