zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: ["regression"] Stéphane= 1 zsh -c 'echo $Stéphane'
Date: Wed, 7 Oct 2015 14:15:23 +0100	[thread overview]
Message-ID: <20151007131522.GA7627@chaz.gmail.com> (raw)
In-Reply-To: <151006084416.ZM5546@torch.brasslantern.com>

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.

IOW,

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:
http://thread.gmane.org/gmane.comp.standards.posix.austin.general/690
)

> 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.
> 
> POSIX_IDENTIFIERS <K> <S>
>      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.

-- 
Stephane


      parent reply	other threads:[~2015-10-07 13:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-06 11:04 ["regression"] Stéphane=1 " Stephane Chazelas
2015-10-06 15:44 ` ["regression"] Stéphane= 1 " Bart Schaefer
2015-10-06 18:59   ` ZyX
2015-10-06 19:29     ` Stephane Chazelas
2015-10-07 13:15   ` Stephane Chazelas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151007131522.GA7627@chaz.gmail.com \
    --to=stephane.chazelas@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).