Martijn Dekker dixit:

>For non-assignment arguments (which would include arguments to 'export',
>'typeset' and the like that may look like assignments but for the
>purposes of shell grammar are no such thing), tilde expansion is only
>provided for at the beginning of each argument (meaning, it's not
>provided for at all in those assignment-like arguments).

That is unfortunately not entirely correct.

It is already provided for in the current spec that “export” and
“readonly” have arguments not of the form “word” but “name=word”,
meaning “export foo=~/bar:~/baz” sets foo to “$HOME/bar:\~/baz”.

And then, there comes http://austingroupbugs.net/view.php?id=351
which is the “more expand-y” thing I wrote about. It started as
making the arguments to, for example, export into assignment con‐
texts, but continues:

| This proposal mandates the historical ksh behavior, even though it renders

But yes, this would certainly affect neither 'scp foo bar:~baz/'
(not a “variable assignment” in either parameter or symbol form)
nor even 'echo a=~/b' (not a special built-in, even though shells
can define their own special built-in utilities, we do this only
for things like typeset, local, etc).

http://austingroupbugs.net/view.php?id=351#c943 is apparently the
currently supposed reading. Still affects “declaration utilities”
only, and only for words that are valid “variable assignment”s.

(Note that symbol=word leads to unspecified results, so we *can*
allow “typeset foo[1]=bar:~/baz” to expand in mksh even in POSIX
mode.) I’ll also want to make the upcoming new “\builtin” builtin
a declaration utility under “certain conditions”, like “command”.
(Rationale: “\builtin” is no valid function name and never expanded
as an alias, and we really need something like this to allow for
both scripts and the shell itself to call internal code, like with
-Bsymbolic, independent of whatever the user did.)

Fun thing about this: mksh already (mostly? need to check) does
this in POSIX mode:

tg@blau:~ $ mksh -o posix -c 'HOME=/tmp; command command export a=~; echo "$a"'
/tmp
tg@blau:~ $ mksh -o posix -c 'HOME=/tmp; command command echo a=~'
a=~
tg@blau:~ $ mksh -o posix -c 'HOME=/tmp; echo a=~:~'
a=~:~
tg@blau:~ $ mksh -o posix -c 'HOME=/tmp; set "1 b=2"; export a=$1; printf 
"%s\\n" "$a" e=$1'
1 b=2
e=1
b=2
tg@blau:~ $ mksh -o posix -c 'HOME=/tmp; var=foo; export $var=~; env | grep 
foo='
foo=~

For some reason, mksh uses lexical analysis on this:

tg@blau:~ $ mksh -o posix -c 'HOME=/tmp; var=export; $var a=~; echo "$a"'
~

But this is consistent with AT&T ksh93 now.

So this is mostly a documentation issue, especially for the
(currently sadly incomplete anyway) “differences with FPOSIX”
chapter.

I’ll review a bit more and fix things.

bye,
//mirabilos
-- 
Stéphane, I actually don’t block Googlemail, they’re just too utterly
stupid to successfully deliver to me (or anyone else using Greylisting
and not whitelisting their ranges). Same for a few other providers such
as Hotmail. Some spammers (Yahoo) I do block.

Reply via email to