Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: RFC PATCH: stop lowercasing messages from strerror



Mikael Magnusson wrote on Tue, 17 Nov 2026 11:49 +00:00:
> Originally reported in debian bug 419233 and forwarded as workers/23274.
>
> ---
>
>> It's not a uniform standard in English, even taking away the technical
>> issues (i.e. it's not simply a kludge in Bash), so from the language
>> point of view I don't think there's any problem in changing it.
>> 
>> The issue is likely to be people matching on error messages in tests ---

Fair point.  However, people having to update their tests is a one-time
cost, and by incurring it we align zsh's behaviour from here on with
most other tools' behaviour and, I therefore suspect, most people's
expectations.

Also, blindly lowercasing a word can change its meaning (e.g.,
"Polish", "Bob", [whatever the codename of the latest Ubuntu is]), so we
shouldn't do that.

Also, this lowercasing can create misspellings in English too — e.g.,
when the message starts with an acronym:
.
    % errno -l | perl -anE 'say "@F" if $F[2] =~ /^[A-Z][A-Z]/'
    EDOTDOT 73 RFS specific error
    % 
.
We shouldn't print "rFS specific error".

>> which could happen in other languages with Latin character sets, so
>> specialising English isn't a fix.  I have absolutely no idea how common
>> this would turn out to be.  I think we'd have to apply the patch and ask
>> people to look for knock-on effects.
>
> Here's a patch against the current code, including adjustments for our
> own tests, for reference.
>
> It would have been nice if strerror returned text in lower case, since
> uppercasing is somewhat less problematic, but I suppose it's a bit late
> to lobby for that.
>
> I also realized that my consistency argument somewhat falls on the fact
> that every other error message in zsh is still printed in lower case :).
>

> Even if we decide to keep the lowercasing, it should probably at least
> be made to work on multibyte text, or perhaps we should just use
> strerror_l when it exists (since POSIX.1-2008 if my manpage is to be
> believed) with a "C" locale so that all error messages are in english,
> since our other messages aren't translated anyway?

I would expect someone who runs with LC_MESSAGES=foo to prefer "some
messages are in foo and some are untranslated" to "all messages are untranslated".

Besides, even programs that do localize their messages still print
unlocalized messages when a particular message hasn't been translated;
i.e., it's not unheard of to see a bit of English in the middle of an
otherwise-localized session.

Cheers,

Daniel

>  Src/utils.c           | 11 +----------
>  Test/A01grammar.ztst  |  2 +-
>  Test/A04redirect.ztst | 16 ++++++++--------
>  Test/A08time.ztst     |  2 +-
>  Test/B01cd.ztst       |  2 +-
>  Test/E01options.ztst  | 10 +++++-----
>  6 files changed, 17 insertions(+), 26 deletions(-)
>
> diff --git a/Src/utils.c b/Src/utils.c
> index 372d2a8283..bc036128b3 100644
> --- a/Src/utils.c
> +++ b/Src/utils.c
> @@ -296,7 +296,6 @@ zerrmsg(FILE *file, const char *fmt, va_list ap)
>      int olderrno;
>      char errbuf[ERRBUFSIZE];
>  #endif
> -    char *errmsg;
> 
>      if ((unset(SHINSTDIN) || locallevel) && lineno) {
>  #if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
> @@ -353,15 +352,7 @@ zerrmsg(FILE *file, const char *fmt, va_list ap)
>  		    errflag |= ERRFLAG_ERROR;
>  		    return;
>  		}
> -		errmsg = strerror(num);
> -		/* If the message is not about I/O problems, it looks better *
> -		 * if we uncapitalize the first letter of the message        */
> -		if (num == EIO)
> -		    fputs(errmsg, file);
> -		else {
> -		    fputc(tulower(errmsg[0]), file);
> -		    fputs(errmsg + 1, file);
> -		}
> +		fputs(strerror(num), file);
>  		break;
>  	    /* When adding format codes, update the comment above zwarning(). */
>  	    }
> diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
> index eea6ede2b3..906c6a4ca8 100644
> --- a/Test/A01grammar.ztst
> +++ b/Test/A01grammar.ztst
> @@ -647,7 +647,7 @@
> 
>    . ./nonexistent
>  127: Attempt to "." non-existent file.
> -?(eval):.:1: no such file or directory: ./nonexistent
> +?(eval):.:1: No such file or directory: ./nonexistent




Messages sorted by: Reverse Date, Date, Thread, Author