From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16522 invoked from network); 14 Feb 2021 21:19:58 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 Feb 2021 21:19:58 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1613337598; b=1eI2sujWDTbeGlvUE31j9SjwWAlZAnOpbQUvcYijamVxNQ95RgJXVnU7jDy//zSNS6E/TqDOsN 96+TsmUOQQQe2XBchHJbNLcIqYVG66HbTOlt3NkQY4Vh8lzP7PVZIiSTEUZlNLDUIx0QCI41tI kA3JnuNPT98TaUbItW4XSGwT3631adP+whac6dxf5SmQLst+wDVb6l9fsiIhj1iBqWQOwMn3at xWzA6eMbMdXwVaMxs9/vA/Uqyg2eTLU0KSkRylb+5zXWxH3G7ekHwM8XdmNRQ0VV65zwmTdexn fQAQ53a6PlcQqVdfmynq/R3GERPXBw0Iff6XYzJy/Yczmw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1613337598; bh=QZdGG6b3QmmRkig61bO/Jb/JnadCzamlghNGAxLDOko=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature; b=0UGfjMFJWNiBRcLYe5mYHpVJ6DRBDQ0vYtSCJhIelXHC1xm8eZB6IVcOkzKSApBtA/yCK2Tc0j YC4/0Qr3xKYXHfhsHDZJc3Q7bYQMBmxT/S2oiNPc1lzdVphkUOwmJk4qkwanoBwjGgTGCoPZgU nNWYOz/iGeWVxK8ee2+xeUL28cC58qdr+2RD6QcqKW4fyYa++RzZokb/ApuJSJ+b3ZQH5r3fqI 2vnojv76QEmHwP4tqguceZglDRLQu75RVLpv22c2sGiFnC+cGQ8fqI/QpMcVPLjRIb8xSTAzbl r2Crg5fh6vvf30dOezDxtEUiz4s6z5q3rwghN9uorYt4Hg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=lspobDUIicNGm5FU6AJGof5EQhuVj+1DAlUcNGtmHYc=; b=ox++lZ4ClZzbM66110PV3GoiDi 491uvWu4qvAHbB7TIrMkk66CkH9brm0LogqOO8bCNqVKDq4BlLbxtmVu5qzvbAm6GBo73XmynUZ62 nwrr1X8p2Bpo9WTulnHyX3JaMjAevhTK1X+Xou2wOuC4ykjH0kDScA9R5jwBJPHflMz9wdAv2XQ6r tuvDi30LdEhzxEj2aIv8WQzqnTffrpct9F9fLqVak3AeH86o4IFuFhlRyhTJFiVoywZJblXmc1li9 xe0e3BX5Qx9XM2MxdOPHwq/kF9t2iRNeeUPpJ2KevHauyJMU1JMnfD3wEJqjhPYATjfvyVw4JWcaY ieEGm+9g==; Received: from authenticated user by zero.zsh.org with local id 1lBOo6-000670-1u; Sun, 14 Feb 2021 21:19:54 +0000 Authentication-Results: zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none Received: from joooj.vinc17.net ([155.133.131.76]:39838) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lBOnb-0005kZ-Ob; Sun, 14 Feb 2021 21:19:24 +0000 Received: from smtp-zira.vinc17.net (128.119.75.86.rev.sfr.net [86.75.119.128]) by joooj.vinc17.net (Postfix) with ESMTPSA id E8FFD2FF; Sun, 14 Feb 2021 22:19:22 +0100 (CET) Received: by zira.vinc17.org (Postfix, from userid 1000) id 8D12BC2105E; Sun, 14 Feb 2021 22:19:22 +0100 (CET) Date: Sun, 14 Feb 2021 22:19:22 +0100 From: Vincent Lefevre To: zsh-users@zsh.org Subject: Re: detect pipe Message-ID: <20210214211922.GA2302738@zira.vinc17.org> Mail-Followup-To: zsh-users@zsh.org References: <14ce37b2-35ca-6002-474a-7de5d6626a66@eastlink.ca> <05c3d2ba-6a00-9480-e2a8-685432e2442c@eastlink.ca> <20210214173138.GA2298446@zira.vinc17.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/2.0.5+111 (106ff19a) vl-132933 (2021-02-08) X-Seq: 26515 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: On 2021-02-14 11:33:11 -0800, Bart Schaefer wrote: > On Sun, Feb 14, 2021 at 9:31 AM Vincent Lefevre 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 - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)