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 9354 invoked from network); 24 Jun 2021 09:07:22 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 24 Jun 2021 09:07:22 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1624525642; b=hqblMteaPO7FMtJe6BairJpkOjyE0HT9LV9auv7s87XOK5Ky5yU8kSy30ebLDcYZOmjJZ52Fsn CtFFvAfUCu17tWyx1XKo4b1dxKb3dR5nsm5GyJtNccYMZze+DWuB6r1cLHFhzn29Ua55miee5X 7MKMZqPF6D+5kcCrj5Wr4FEoOSIEplbqPq+zWRnR0lKDTkCksaPwsUxnhBopPiPogw45FbUngJ TFs4YvDdSvUXYtQQYkBiTjSOQbrdumY4kJ6OnJ+GOMiEEYXSsAr+WR6jqMpL1LGOmnTDXQL4Ed /vpHYUNiNrtB3dELVVB7cPcdDGdXMgjJ2oyypTwQs7XuXw==; 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=1624525642; bh=GHqTMqYEwv7tdjxheuL7uqUzJBeZOkFfUeHTVaUVIRk=; 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:Cc:To:From:Date:DKIM-Signature; b=GQ99bONz2WwoeJKg4+xr2z53iU0t5PVAATOqZl89cabNjHcw/QaGsfdKg8pxJLE7BbwCNRbj3d dKyTHvmA7EziaUjTS5GAbYYxdL8kbAW3Igi6jesSd6NGU4qDQH64MANw/mdw+sF/7dWgkBT3PZ oEtLp2hxDGpJANxkqk0jzMzZ7tzCSSpDFTqudkhBnyuTci279+OZl22G8t+IIu137pC/Pp2mMt vrjJ3OY3Bq/+ttQzH4RPvuXvvfLglj9Qkm4624ZezEmVoj1KNM16DZMSinmKbwcBTPQqNY6ulf Pp4sFXpfwJZIClBn+v+8x9wBHUPrxbHBN1M6XPZfBeX5NA==; 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:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=K03grjLXl195E8Jk/xJ47xENVIq20Y901bVZr7ffGto=; b=TlZnNpm5kAUati/g88QsCGVZqs Xs3dW7WRLHVv2eV6Hutz0Pxuq80CUv2gOhz1c7slknPoeaL4yGd94+kHCEQQjfID1eKCeID/zx6la KoqSK/e2oU4ZBftnkcbCTe0SZBVdxPoMws4Ilqs06aHZIvBDc16Rt7gpt2Qmu6KyOaxa9Qh7MSvdP bryslZIcDOWjWRrETwra31Bw398IiE+ldoydNradOMM7ts3mVr12Zm0az7tQfyyn0llNesWZ3QACS phghlzPI2DfA+D7fb/SYGp7ghj6wYC7rupNxB6AVdmH3g+9lqOXbK9wiG0YOV9eB5wRu78cL2v/0u fxi0iT1Q==; Received: from authenticated user by zero.zsh.org with local id 1lwLKT-0002P5-L8; Thu, 24 Jun 2021 09:07:21 +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]:37010) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lwLKH-00027G-MD; Thu, 24 Jun 2021 09:07:10 +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 4777C46; Thu, 24 Jun 2021 11:07:09 +0200 (CEST) Received: by zira.vinc17.org (Postfix, from userid 1000) id E6DA0C237F5; Thu, 24 Jun 2021 11:07:08 +0200 (CEST) Date: Thu, 24 Jun 2021 11:07:08 +0200 From: Vincent Lefevre To: zsh-workers@zsh.org Cc: Bart Schaefer Subject: Re: [BUG] builtin echo doesn't check write error Message-ID: <20210624090708.GA172975@zira.vinc17.org> Mail-Followup-To: zsh-workers@zsh.org, Bart Schaefer References: <20210609140940.GA813383@zira.vinc17.org> <20210609181617.k5jbq3z37lt7ry5s@chazelas.org> <20210624084739.GB170692@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: <20210624084739.GB170692@zira.vinc17.org> X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/2.1+10 (5cc548e1) vl-138565 (2021-06-20) X-Seq: 49110 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 2021-06-24 10:47:39 +0200, Vincent Lefevre wrote: > Note also about the bug in echo/print/etc., this actually seems > to affect *all* builtins. For instance: > > zira% (exec >&-; echo) > zsh: write error: bad file descriptor > zira% (exec >&-; echo >&-) > zira% (exec >&-; print) > zsh: write error: bad file descriptor > zira% (exec >&-; print >&-) > zira% (exec >&-; printf "\n") > zsh: write error: bad file descriptor > zira% (exec >&-; printf "\n" >&-) > zira% (exec >&-; pwd) > zsh: write error: bad file descriptor > zira% (exec >&-; pwd >&-) > zira% (exec >&-; history) > zsh: write error: bad file descriptor > zira% (exec >&-; history >&-) > zira% That was about the error messages. But in all cases, the exit status is 0: zira% (exec >&-; echo; echo $? >&2) zsh: write error: bad file descriptor 0 zira% (exec >&-; echo >&-; echo $? >&2) 0 zira% (exec >&-; print; echo $? >&2) zsh: write error: bad file descriptor 0 zira% (exec >&-; print >&-; echo $? >&2) 0 zira% (exec >&-; pwd; echo $? >&2) zsh: write error: bad file descriptor 0 zira% (exec >&-; pwd >&-; echo $? >&2) 0 zira% (exec >&-; history; echo $? >&2) zsh: write error: bad file descriptor 0 zira% (exec >&-; history >&-; echo $? >&2) 0 The other shells differ, but for ksh, posh and busybox sh, in an inconsistent way (I assume that this is a bug in these shells): $ zsh -c 'exec >&-; echo; echo $? >&2; pwd; echo $? >&2' zsh:1: write error: bad file descriptor 0 zsh:1: write error: bad file descriptor 0 $ sh -c 'exec >&-; echo; echo $? >&2; pwd; echo $? >&2' sh: 1: echo: echo: I/O error 1 sh: 1: pwd: pwd: I/O error 1 $ bash -c 'exec >&-; echo; echo $? >&2; pwd; echo $? >&2' bash: line 1: echo: write error: Bad file descriptor 1 bash: line 1: pwd: write error: Bad file descriptor 1 $ yash -c 'exec >&-; echo; echo $? >&2; pwd; echo $? >&2' echo: cannot print to the standard output: Bad file descriptor 1 pwd: cannot print to the standard output: Bad file descriptor 1 $ busybox sh -c 'exec >&-; echo; echo $? >&2; pwd; echo $? >&2' sh: write error: Bad file descriptor 1 1 (for busybox sh, the inconsistency is on the presence of the error message). $ ksh93 -c 'exec >&-; echo; echo $? >&2; pwd; echo $? >&2' 1 0 $ mksh -c 'exec >&-; echo; echo $? >&2; pwd; echo $? >&2' 1 0 $ posh -c 'exec >&-; echo; echo $? >&2; pwd; echo $? >&2' 1 0 -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)