|
From: | Paul Eggert |
Subject: | Re: [PATCH v2] Ensure standard file descriptors are open on start |
Date: | Fri, 28 Aug 2020 08:59:03 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 8/28/20 6:52 AM, Zack Weinberg wrote:
I think that for 2.70 we should make fd 0 read-only and 1,2 write-only here, and revisit this afterward -- when we're not in a release freeze we can think about things like turning on set -e mode.
Sounds good.In the longer term I doubt whether set -e is the way to go. I recall some old shells mishandling it (e.g., with 'set -e' the command 'A || B' would cause the shell to exit when A failed). And I suspect the use of 'set -e' to detect shell errors is problematic even today. 'set -e' is intended more as a debugging aid than as a programming facility.
One other issue: with some shells 'printf x >/dev/full' succeeds because they buffer output, so you cannot rely on printf exit status telling you that the output actually worked. One can work around this problem by using a utility like 'cat' that doesn't play the game, but of course this has its own issues....
[Prev in Thread] | Current Thread | [Next in Thread] |