From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-users@zsh.org
Subject: Re: detect pipe
Date: Sun, 14 Feb 2021 22:19:22 +0100 [thread overview]
Message-ID: <20210214211922.GA2302738@zira.vinc17.org> (raw)
In-Reply-To: <CAH+w=7Y=3osi+0LHadHAdEQVyPWHsX0a5V2iZGCdSE3VF0=E8w@mail.gmail.com>
On 2021-02-14 11:33:11 -0800, Bart Schaefer wrote:
> On Sun, Feb 14, 2021 at 9:31 AM Vincent Lefevre <vincent@vinc17.net> wrote:
> > Closing stdin is a bad idea, as this can break stdout redirection,
> > and this may be out of control of the commands. See
> >
> > https://sourceware.org/bugzilla/show_bug.cgi?id=682
>
> IMO that's just silly. If stdin/stdout were never supposed to be
> closed, why has the standard shell had <&- and >&- for its entire
> existence? Why wouldn't those be syntax errors when a file descriptor
> number is not provided if you're never supposed to use them?
To make the rule the same for all file descriptors and all redirection
type?
Note also that something like
{ cat < file } <&-
is OK (the <&- is useless here, but there might be cases where this
could be useful).
In any case, it is a bad idea to use a closed standard fd, unless
you know that this is supported by the command. For instance, note
the difference with "cat" from the GNU coreutils 8.32:
$ echo foo > file
$ cat <&- file -
foo
cat: -: Bad file descriptor
cat: closing standard input: Bad file descriptor
$ cat < /dev/null file -
foo
$
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
next prev parent reply other threads:[~2021-02-14 21:19 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-27 16:45 Ray Andrews
2021-01-27 23:59 ` Bart Schaefer
2021-01-28 4:57 ` Ray Andrews
2021-01-28 6:16 ` Bart Schaefer
2021-01-28 10:08 ` Vincent Lefevre
2021-01-28 10:28 ` Vincent Lefevre
2021-01-28 15:05 ` Ray Andrews
2021-01-28 15:45 ` Ray Andrews
2021-01-28 20:58 ` Bart Schaefer
2021-01-28 20:59 ` Bart Schaefer
2021-01-29 1:17 ` Ray Andrews
2021-01-29 2:50 ` Bart Schaefer
2021-01-29 3:21 ` Ray Andrews
2021-01-30 0:29 ` Bart Schaefer
2021-01-30 14:26 ` Ray Andrews
2021-01-30 19:00 ` Bart Schaefer
2021-01-30 19:19 ` Ray Andrews
2021-01-31 19:12 ` Ray Andrews
2021-01-31 21:28 ` Bart Schaefer
2021-02-14 17:31 ` Vincent Lefevre
2021-02-14 19:33 ` Bart Schaefer
2021-02-14 20:33 ` Ray Andrews
2021-02-14 21:20 ` Bart Schaefer
2021-02-14 22:25 ` Ray Andrews
2021-02-14 21:24 ` Vincent Lefevre
2021-02-14 21:19 ` Vincent Lefevre [this message]
2021-02-14 21:24 ` Bart Schaefer
2021-02-14 21:38 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210214211922.GA2302738@zira.vinc17.org \
--to=vincent@vinc17.net \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).