bug-bash
[Top][All Lists]
Advanced

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

Re: NL character removed after \\ in command substitution


From: Chet Ramey
Subject: Re: NL character removed after \\ in command substitution
Date: Tue, 17 Aug 2021 11:23:16 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

On 8/16/21 10:28 PM, Haojun Bao wrote:

> Bash Version: 5.0
> Patch Level: 3
> Release Status: release
> 
> Description:
> 
> A bug found in parse.y, that will treat reading of COMMAND and
> $(COMMAND) differently, despite the info manual saying that:
> 
>> When the old-style backquote form of substitution is used, backslash
>> retains its literal meaning except when followed by '$', '`', or '\'.
>> The first backquote not preceded by a backslash terminates the command
>> substitution.  When using the '$(COMMAND)' form, all characters between
>> the parentheses make up the command; none are treated specially.
> 
> It seems the NL after \\ will be removed when run as $(COMMAND) in parse.y?
> 
> Repeat-By:
> 
> This command will output $'hello \\\nworld\n':
> 
> cat <<EOF
> hello \\
> world
> EOF
> 
> This command will output $'hello \\world\n' (missing the \n after \\):
> echo "$(
> cat <<EOF
> hello \\
> world
> EOF
> )"

Thanks for the report. This is still a problem in bash-5.1, but has been
fixed in the devel branch for a while.

Chet

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