help-bash
[Top][All Lists]
Advanced

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

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


From: Philipp Schrader
Subject: [Help-bash] Differences in heredocs between process substitution and shell substitution
Date: Fri, 18 Jul 2014 18:41:36 -0700

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]