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: Andreas Kusalananda Kähäri
Subject: Re: NL character removed after \\ in command substitution
Date: Tue, 17 Aug 2021 08:32:35 +0200

On Tue, Aug 17, 2021 at 10:28:16AM +0800, Haojun Bao wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -g -O2
> -fdebug-prefix-map=/build/bash-2bxm7h/bash-5.0=.
> -fstack-protector-strong -Wformat -Werror=format-security -Wall
> -Wno-parentheses -Wno-format-security
> uname output: Linux bhj-pc1 5.10.0-0.bpo.5-amd64 #1 SMP Debian
> 5.10.24-1~bpo10+1 (2021-03-29) x86_64 GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
> 
> 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
> )"


Consider quoting the here-document:

        cat <<'EOF'
        hello \\
        world
        EOF
        )"


-- 
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.



reply via email to

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