Sujet : Re: Using << and an output pipe together in shell (bash)
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.unix.shellDate : 01. Nov 2024, 16:19:47
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20241101081200.462@kylheku.com>
References : 1 2 3
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-10-31, Kenny McCormack <
gazelle@shell.xmission.com> wrote:
In article <87r07v99wd.fsf@bsb.me.uk>, Ben Bacarisse <ben@bsb.me.uk> wrote:
...
I think you need "| \" at the end of this line. At least that's what I
usually do and it seems to work.
>
It is not generally necessary to put a backslash at the end of a line that
ends with | (in shell script).
The << feature works outside of the ordinary shell grammar, fetching
data in a line-oriented way until the delimiter.
If you have multiple occurrences, both their data parts go after
the command:
cmd1 << EOF | cmd2 << EOF | cmd3 << EOF
data1
EOF
data2
EOF
data3
EOF
Actual run with && rather than |:
$ cat << EOF && cat << EOF && cat << EOF
foo
EOF
bar
EOF
xyzzy
EOF
foo
bar
xyzzy
It looks like the implementation of << pulls logical lines (after
backslash folding) during parsing.
If this entire command pipe were parsed first:
cmd1 << EOF | cmd2 << EOF | cmd3 << EOF
and then a second pass took place to fetch the EOF-delimited pieces of
syntax that it requires, then it could contain artbitrary backslahes.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca