bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tilde expandion for values of long options


From: Chet Ramey
Subject: Re: Tilde expandion for values of long options
Date: Sat, 08 Dec 2007 23:18:37 -0500
User-agent: Thunderbird 2.0.0.9 (Macintosh/20071031)

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    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]