On 7/20/20 4:28 AM, Robert Elz wrote:
>     Date:        Sun, 19 Jul 2020 15:21:07 -0400
>     From:        Chet Ramey <chet.ra...@case.edu>
>     Message-ID:  <5f066ef0-1fed-ad5b-d564-490268d32...@case.edu>
> 
>   | Maybe, but Posix says this isn't a variable assignment context, as POSIX
>   | defines variable assignments, and technically  the shell shouldn't perform
>   | tilde expansions after `=' or `:' at all. You could argue that bash has a
>   | bug here in that it expands the tilde after the `='.
> 
> It may also be that this is a bug in POSIX, as all ksh shells seem to
> act the way that bash does, expanding the first ~ but not the secpod.
> Most other shells expand neither, except the NetBSD shell which treats
> this as a var assignment (which it is really, however explained away in
> POSIX) and expands both.
> 
> It is likely that if someone were to file a posix bug report about this,
> it would turn into "unspecified" whether ~ expansion is done in that context.

You can make a case for the bash/ksh tilde expansion: the word
expansion is ${PARAM:=WORD}, and the WORD is subject to tilde expansion
according to the enumerated list in 2.6.2. Since the first character of
WORD is a tilde, if you say the tilde-prefix stops at the `:', the tilde
gets expanded, and since it's not an assignment, the `:~' doesn't trigger
subsequent tilde expansion. Bash has done this since at least the early 1.x
days (at least 1.10), and there is code to handle that case in bash to this
day.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to