Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: sysexits.h codes? (was: Re: [RFC][PATCH] `newuser` prompt theme)
On Mon, May 3, 2021 at 7:04 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Marlon Richert wrote on Mon, May 03, 2021 at 14:36:01 +0300:
> >
> > zsh: NO_CLOBBER: file exists; use >| to override
> >
> > It would give you the right keywords to use in a web search.
>
> +1 on putting the option name first.
>
> Not sure whether putting the strerror(3) string in the middle would
> work well in all cases. Convention — codified in errx(3) and friends,
> and compare Perl's «die "foo"» without a trailing newline — is that
> extra information is appended, rather than surrounded. The latter could
> also lead to ambiguous or unclear grammatical structures.
>
> Furthermore, the extra advice in the error wouldn't always be
> appropriate — for instance, when the error is EACCES ("Permission
> denied").
Well, of course not. The advice above is specific to NO_CLOBBER. ;)
In all seriousness, though: I'm fine with not providing advice for
errors like EACCES, because those are not specific to the shell. For
all errors specific to shell features, though, (such as NO_CLOBBER,)
having a short, error-specific piece of advice would be a tremendous
help in making the shell's features easier to discover and easier to
understand.
> Well, suit yourself,
Tweet or plaid? ;)
> but unless someone else shows up to drive the discussion, it'll likely be left at that.
All right, if you insist… :)
I've given it some more thought and the best option, I think, would be
as follows:
* Have an associative array $sysexits.
* Let the keys be the return codes and the values be the exact
descriptions that PRINT_EXIT_VALUE shows (minus the 'zsh: ' prefix and
command suffix, of course).
* Include all of 0 (success), 1 (failure), 2 (error), 64 - 78
(sysexits.h), 126 (command not executable), 127 (command not found),
and 129 - 159 (signal.h). (Anything else I'm forgetting?)
* $sysexits could either be built in, like $signals, or be available
through a module.
Additional features for consideration:
* Make $sysexits editable, so that you can modify what PRINT_EXIT_VALUE outputs.
* Let PRINT_EXIT_VALUE support formatting in the form of prompt escape
sequences.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author