[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How to let a command take multiple here-doc?
From: |
Eric Blake |
Subject: |
Re: [Help-bash] How to let a command take multiple here-doc? |
Date: |
Fri, 29 May 2015 06:44:41 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
On 05/29/2015 06:29 AM, Eric Blake wrote:
>
> On systems with /dev/fd, you can do:
Bash documents that it special-cases /dev/fd/n as the target of a
redirection operator, but that is different than my usage here.
>
> $ cat - /dev/fd/4 <<EOF 4<<EOF
>> a
>> EOF
>> b
>> EOF
> a
> b
>
> for a single cat process that reads from two different fds. But it's
> such an unusual idiom that I don't recommend it for code trying to be
> portable.
Meanwhile, this points out a bug in 'man bash'. Whereas for most
redirections, the manual lists the optional '[n]' for the default fd of
0 or 1, the heredoc redirection fails to mention [n]:
The general format for redirecting input is:
[n]<word
The general format for redirecting output is:
[n]>word
The general format for appending output is:
[n]>>word
The format of here-documents is:
<<[-]word
here-document
delimiter
It should be "[n]<<[-]word".
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature