help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Differences in heredocs between process substitution and


From: Eduardo A . Bustamante López
Subject: Re: [Help-bash] Differences in heredocs between process substitution and shell substitution
Date: Sat, 19 Jul 2014 16:49:50 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Philipp.

You're right to be confused, because there's indeed a problem when you mixup
heredocs and process substitution. See this thread in the bug-bash
mail archive: https://lists.gnu.org/archive/html/bug-bash/2014-06/msg00056.html

On Fri, Jul 18, 2014 at 06:41:36PM -0700, Philipp Schrader wrote:
> Hi,
> 
> I'm looking for help in understanding why the following two pieces of
> behave differently. I apologize for the lengthy e-mail. I tried to make my
> examples as short as I could.
> 
> First, a piece of code that I understand:
> var=$(cat <<EOT
> Hello World
> EOT
> )
> echo "$var"
> 
> cat <(cat <<EOT
> Hello World
> EOT
> )
> 
> This produces the output:
> Hello World
> Hello World
> 
> Now, if I change the content of the heredoc to Hello 'World (notice the
> apostrophe) then bash throws an error on the variant with process
> substitution:
> Hello 'World
> test.sh: line 12: bad substitution: no closing `)' in <(cat <<EOT
> Hello 'World
> EOT
> )
> 
> Then, if I change the content of the heredoc to 'Hello 'World (notice an
> apostrophe before each word) then bash acts like I was expecting:
> 'Hello 'World
> 'Hello 'World
> 
> I run into the same trouble with double quotation marks and I've tried this
> on Ubuntu 12.04 and 14.04 which run bash versions 4.2.25(1)-release and
> 4.3.11(1)-release, respectively.
> 
> My best guess is that the quotation marks are somehow messing with the
> parsing of the process substitution.
> 
> I feel like I should be able to do what I want to do in the failing example
> (with a single apostrophe in the heredoc). Am I misunderstanding how it
> works?
> 
> Thanks,
> Philipp



reply via email to

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