Jan Schampera wrote:
> Per Starbäck wrote:
> 
>> Repeat-By:
>>      echo foo=~root          => foo=/root
>>      echo --foo=~root        => --foo=~root
>>
>>      In the second one there is no expansion.
> 
> From my understanding of the manpage and the SUS the first one is
> "wrong", it should not be expanded. I don't say it's useless, I just say
> "from my understanding of the manpage and SUS".

You're correct that Posix doesn't say either form should be expanded.
The first is a bash extension (and only bash -- it isn't done when bash
is running in posix mode).

Bash identifies words that satisfy the syntactic requirements of assignment
statements while parsing, and, as an extension, performs Posix-style tilde
expansion on them during word expansion.  Assignment statements that are
arguments to `assignment builtins' like declare, export, readonly and the
like are treated exactly like assignment statements preceding command
words; other assignment statements undergo tilde expansion only.

And, before you ask, the second example is not recognized as an assignment
word, since the characters preceding the `=' do not constitute a valid
shell identifier.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    [EMAIL PROTECTED]    http://cnswww.cns.cwru.edu/~chet/


Reply via email to