[klibc] klibc sh doesn't support switching LC_* during a script/session

Thorsten Glaser tg at mirbsd.de
Mon Jan 24 22:19:42 PST 2022


Christoph Anton Mitterer dixit:

>e.g. https://unix.stackexchange.com/a/383390/474076).

Just add a trailing period or slash; POSIX requires them to
be identically encoded across all supported locales:

     * The encoded values associated with <period>, <slash>, <newline>,
       and <carriage-return> shall be invariant across all locales
       supported by the implementation.

And:

   […] Likewise, the byte values used to encode <period>, <slash>,
   <newline>, and <carriage-return> shall not occur as part of any other
   character in any locale.

I’ve been using an x myself, but will probably switch to… hmm…
a period (more flexible to use).

x=$(somecommand; echo .); x=${x%.}

(Note the ‘.’ is not a regular expression there.) This will
result in exactly the output of “somecommand”, truncated at
the first NUL, if any, with trailing newlines preserved.

This should do in klibc dash, too.

(Incidentally, a method using Unicode characters won’t, as
POSIX puts requirements on the application as well; mixing
encodings is not permitted.)

bye,
//mirabilos
-- 
FWIW, I'm quite impressed with mksh interactively. I thought it was much
*much* more bare bones. But it turns out it beats the living hell out of
ksh93 in that respect. I'd even consider it for my daily use if I hadn't
wasted half my life on my zsh setup. :-) -- Frank Terbeck in #!/bin/mksh



More information about the klibc mailing list