bug-bash
[Top][All Lists]
Advanced

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

Re: "shell-expand-line" wrongly(?) expanded $'foo' to $foo


From: Chet Ramey
Subject: Re: "shell-expand-line" wrongly(?) expanded $'foo' to $foo
Date: Wed, 1 Jul 2020 15:38:59 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

On 7/1/20 8:48 AM, Clark Wang wrote:
> See the following example (tested with bash 5.0.7):
> 
> 
> # bind -q shell-expand-line
> shell-expand-line can be invoked via "\e\C-e".
> 
> # echo $PWD      # press ESC C-e
> # echo /root
> 
> # echo $( pwd )  # press ESC C-e
> # echo /root
> 
> # echo $'foo'    # press ESC C-e
> # echo $foo
> 
> 
> Is this a bug?

I suppose it is. $'...' isn't a word expansion, it's a form of quoting that
gets translated and transformed into '...' by the parser. When the word
expansion code sees $'...', unexpectedly, it just performs the usual quote
removal.

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