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

Re: ["regression"] Stéphane= 1 zsh -c 'echo $Stéphane'

2015-10-06 08:44:16 -0700, Bart Schaefer:
> This is discussed in the thread starting at workers/34004 and leading
> up to workers/34015.
> Nobody ever commented on whether the environment is allowed to contain
> names with the high-order bit set, but POSIX identifiers cannot, so it
> stands to reason you can't import something with that shape of name.

Note that it's not so much about the 8th bit (0-9 in EBCDIC have
the 8th bit set), but about being _, letters and digits in the
portable character set (0-9 a-z A-Z _).

POSIX doesn't forbid shells importing whatever they want from
the environment AFAICT. Only a POSIX application (script) must
not make use of those that are not valid POSIX identifiers.


env Stéphane=1 sh -c 'echo "${Stéphane}"'

is an invalid inline-script, so it doesn't matter what sh does
with that Stéphane environment variable (as long as it's passed
along unmodified to the commands it executes, though not all
shells do it, and there was a discussion about it some time ago:

> zsh -f -o posixidentifiers -c 'Stéphane=2; echo $Stéphane'
> zsh:1: command not found: Stéphane=2
> éphane
> In effect the environment is always treated as POSIX_IDENTIFIERS.
>      When this option is set, only the ASCII characters a to z, A to Z,
>      0 to 9 and _ may be used in identifiers (names of shell parameters
>      and modules).

Note that while POSIX (AFAICS) requires $Stéphane to be treated
as ${St}éphane, ksh93 and bash (in single-byte character
locales) don't.

The behaviour for ${Stéphane} would be unspecified, so
implementations may do whatever they want there.

Now, I won't be the one complaining if I can't use $Stéphane or
${Stéphane} as a variable name, I never liked the idea of the
syntax of a script being dependant on the locale.


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