[Top][All Lists]

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

Re: Assignment-like word shouldn't be subjected to tilde expansion in PO

From: Chet Ramey
Subject: Re: Assignment-like word shouldn't be subjected to tilde expansion in POSIX mode
Date: Mon, 20 Jul 2020 10:11:59 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 7/20/20 4:28 AM, Robert Elz wrote:
>     Date:        Sun, 19 Jul 2020 15:21:07 -0400
>     From:        Chet Ramey <chet.ramey@case.edu>
>     Message-ID:  <5f066ef0-1fed-ad5b-d564-490268d32427@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

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

reply via email to

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