On 1/27/22 10:18 AM, Harald van Dijk via austin-group-l at The Open Group
wrote:
On 27/01/2022 12:44, Geoff Clare via austin-group-l at The Open Group wrote:
Christoph Anton Mitterer wrote, on 26 Jan 2022:
3) Does POSIX define anywhere which values a shell variable is required
to be able to store?
I only found that NUL is excluded, but that alone doesn't mean that
any other byte value is required to work.
Kind of circular, but POSIX clearly requires that a variable can be
assigned any value obtained from a command substitution that does not
include a NUL byte, and specifies utilities that can be used to
generate arbitrary byte values, therefore a variable can contain any
sequence of bytes that does not include a NUL byte.
Is it really clear that POSIX requires that? The fact that it refers to
"characters" of the output implies the bytes need to be interpreted as
characters according to the current locale, which is a process that can
fail. In at least one shell (yash), bytes that do not form a valid
character are discarded, which makes sense since yash internally stores
variables etc. as wide strings.
Wow, that seems like a bug. Environment variables can contain sequences of
arbitrary non-NULL bytes, and, as long as the portion before the `=' is a
valid NAME, the shell is required to create a variable with the remainder
of the string as its value and pass it to child processes in the
environment. If yash modifies that value because there are sequences that
don't form valid wide characters, that sounds like a problem.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/