with said:
Quoth Eric Pozharski <
[email protected]>:
*SKIP*
Well, if you insist:
| If more than one redirection operator is specified with a command,
| the order of evaluation is from beginning to end.
|
| A failure to open or create a file shall cause a redirection to fail.
|
| 2.7.1 Redirecting Input
|
| Input redirection shall cause the file whose name results from the
| expansion of word to be opened for reading on the designated file
| descriptor, or standard input if the file descriptor is not
| specified.
After reading and further research I must admit that's the only relevant
part. Now I can say, that bash-people and zsh-people read that
differently. POSIX, at least four years ago, says nothing what to do if
one FD is redirected more than once. "the order of evaluation is from
beginning to end" doesn't suppose that what's already evaluated should
be dropped. I've got to conclusion (and I'm not interested in
discussing this with bash-people) that both shells, bash and zsh, are
POSIX compliant.
However, I dare to comment a bit more. There're three concurent ways to
maintain STDIN for commands.
First, what cat(1) does, in essence, is turning files into clean
bytestream. OTOH, there's that puristic proverb about
useless-use-of-cat. And that proverb is mantra. Tell me, shell
wizards, what is more pure:
cat filename | grep word
or
grep -h word filename
And all that bytestream BS is relevant as long as cat(1) is fed with
filenames. Because,
Second comes redirection. It has bonuses, but (I stand corrected) it
comes with price. And that price is so huge that it renders redirection
useless. Isn't this elegant:
cat <<<"### /etc/hosts.allow ###" /etc/hosts.allow \
<<<"### /etc/hosts.deny ###" /etc/hosts.deny | lp
It's not, because it's not portable. What we have here is bash sneaking
it's features and limitations under disguise of compatibility. Good
news is that shell is so long forgotten that it doesn't harm anyone
anymore.
Third is command line tail. Well, we're supposedly talking Perl here,
it's an *interpreted* script, I can do whatever I want with that script.
I just need filenames.
Shortly, zsh wins, bash is lame, we all lose, and now I feel much better.
*CUT*