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


Groups > gnu.bash.bug > #16522

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

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: "shell-expand-line" wrongly(?) expanded $'foo' to $foo
Date 2020-07-01 15:38 -0400
Organization ITS, Case Western Reserve University
Message-ID <mailman.795.1593632348.2574.bug-bash@gnu.org> (permalink)
References <CADv8-ojoKwZknUW1CrppEBBz+-zE8P3QxxzuzmM3qLyYenxcMA@mail.gmail.com> <1530be92-768a-3676-cfe0-511bcea9133b@case.edu>

Show all headers | View raw


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/

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: "shell-expand-line" wrongly(?) expanded $'foo' to $foo Chet Ramey <chet.ramey@case.edu> - 2020-07-01 15:38 -0400

csiph-web