help-bash
[Top][All Lists]
Advanced

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

Re: Line continuation and pipes within command substitution and process


From: Greg Wooledge
Subject: Re: Line continuation and pipes within command substitution and process substitution
Date: Fri, 9 Jul 2021 17:11:18 -0400

On Fri, Jul 09, 2021 at 11:05:37AM -1000, Robin A. Meade wrote:
> Now introduce line continuation:
> 
> #!/bin/bash
> echo "$(cat <<'EOF' \
> | cat \
> | cat \
> | cat
> hello
> EOF
> )"
> 
> 
> Running it on bash-4.4 still gives the expected result:
> 
> bash-4.4$ ./myscript.sh
> hello
> 
> 
> But running it on bash-5.0 gives an unexpected result:
> 
> bash-5.0$ ./myscript.sh
> ./myscript.sh: line 14: warning: here-document at line 12 delimited by
> end-of-file (wanted `EOF')
> ./myscript.sh: line 14: warning: here-document at line 12 delimited by
> end-of-file (wanted `EOF')
> ./myscript.sh: line 13: warning: here-document at line 11 delimited by
> end-of-file (wanted `EOF')
> hello
> EO)

It also fails in bash 5.1.

unicorn:~$ bash-5.1 foo
foo: line 14: warning: here-document at line 12 delimited by end-of-file 
(wanted `EOF')
foo: line 8: unexpected EOF while looking for matching `)'
unicorn:~$ wc foo
 8 16 69 foo

The report of the error being on "line 14" of an 8-line script is
especially amusing.  Or frustrating, I suppose, depending on your
point of view.

Anyway, this is definitely more in bug-bash territory than help-bash
territory.



reply via email to

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