| Deutsch English Français Italiano |
|
<vg0q7d$3tlel$2@news.xmission.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.snarked.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Using << and an output pipe together in shell (bash)
Date: Thu, 31 Oct 2024 20:44:29 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vg0q7d$3tlel$2@news.xmission.com>
Injection-Date: Thu, 31 Oct 2024 20:44:29 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="4117973"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
Bytes: 2281
Lines: 43
Consider this code in a bash script:
(Note: No actual indentation is intended - only shown like this for posting)
someCommand ... << EOF | someOtherCommand
some data
for someCommand
EOF
This should work, right?
In simple cases, it does (seem to) work OK.
However, in the actual real world case, it is more like:
someCommand -x -y "sjdfhk" and more options \
-g and still more options -Q "another option" << EOF |
/usr/lib/ANotherCommand -x "with option" and "more options"
some data
for someCommand
EOF
This time, two things happen:
When edited with GVIM, everything after the line that ends with | is
highlighted as if it was an unterminated string (that is, in a purple/pink
color) and when the above file is dotted, bash complains about "Syntax
error: Unexpected end of file" - as if it never seems the EOF tag.
In the end, I ended up replacing the " << EOF | ANotherCommand ..." construct with:
> >(ANotherCommand ...) << EOF
and all is well. But why? Should this be necessary?
Yes, I know it is hard to debug this w/o specifics, but I really don't
think the specifics matter; they would be hard to reproduce here.
I just want to know if the basic syntax is valid and/or if there is a
better workaround (better than switching to: > >(...))
--
Many North Koreans believe Kim-il-Sung is an "almighty god" who "created
the world" in seven days as a divine spirit millions of years ago, and
came to Earth as a human in 1912 as a messianic figure.