Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16594 > unrolled thread

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

Started byChet Ramey <chet.ramey@case.edu>
First post2020-07-20 10:11 -0400
Last post2020-07-20 10:11 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Assignment-like word shouldn't be subjected to tilde expansion in POSIX mode Chet Ramey <chet.ramey@case.edu> - 2020-07-20 10:11 -0400

#16594 — Re: Assignment-like word shouldn't be subjected to tilde expansion in POSIX mode

FromChet Ramey <chet.ramey@case.edu>
Date2020-07-20 10:11 -0400
SubjectRe: Assignment-like word shouldn't be subjected to tilde expansion in POSIX mode
Message-ID<mailman.229.1595254328.24492.bug-bash@gnu.org>
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
day.

-- 
``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/

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web