From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 5278 invoked from network); 14 Apr 2020 12:38:55 -0000 Received-SPF: pass (primenet.com.au: domain of zsh.org designates 203.24.36.2 as permitted sender) receiver=inbox.vuxu.org; client-ip=203.24.36.2 envelope-from= Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with UTF8ESMTPZ; 14 Apr 2020 12:38:55 -0000 Received: (qmail 16394 invoked by alias); 14 Apr 2020 12:38:49 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45696 Received: (qmail 7479 invoked by uid 1010); 14 Apr 2020 12:38:49 -0000 X-Qmail-Scanner-Diagnostics: from relay12.mail.gandi.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25779. spamassassin: 3.4.4. Clear:RC:0(217.70.178.232):SA:0(-2.6/5.0):. Processed in 2.598638 secs); 14 Apr 2020 12:38:49 -0000 X-Envelope-From: stephane@chazelas.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _nblcust.gandi.net designates 217.70.178.232 as permitted sender) Date: Tue, 14 Apr 2020 13:38:03 +0100 From: Stephane Chazelas To: Daniel Shahaf Cc: zsh-workers@zsh.org Subject: Re: glob qualifier '-' doesn't work correctly on dangling symlinks Message-ID: <20200414123803.2ps5p475l4kiyfmp@chazelas.org> Mail-Followup-To: Daniel Shahaf , zsh-workers@zsh.org References: <20200412012155.7954a35f@tarpaulin.shahaf.local2> <20200412021722.GA1748686@zira.vinc17.org> <20200412070930.etfzj6j2qvd5em7b@chazelas.org> <20200412142544.GA1783815@zira.vinc17.org> <20200412173448.rl3wttigdx5t5wcn@chazelas.org> <20200412233845.GB1831017@zira.vinc17.org> <20200413142257.orwzb4jrgmf7gpoi@chazelas.org> <20200413214149.GA2644627@zira.vinc17.org> <20200414061816.5qfbjyc6w3x34wcz@chazelas.org> <20200414120241.3d8d7246@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200414120241.3d8d7246@tarpaulin.shahaf.local2> User-Agent: NeoMutt/20180716 2020-04-14 12:02:41 +0000, Daniel Shahaf: [...] > Counter-argument: since an ENOMEM during symlink resolution causes > «(-@)» to presume the symlink is broken, the zsh language is > non-deterministic: what «intact-symlink(N-@)» will expand to will > depend on whether there is enough memory at runtime. > > Shouldn't an ENOMEM during expansion of «intact-symlink(N-@)» result in > an error? "In the face of ambiguity, refuse the temptation to guess." > > That is: I think there's a qualitative difference between ENOENT and ENOMEM. [...] ENOMEM/EFAULT/EINVAL are the kind of pathological errors for which I'd say you can't do much more than best effort. If you run out of kernel memory to the point that stat() in your shell fails, or if bits start to randomly flip causing EFAULT/EINVAL, more things are going to fail and an inaccurate glob expansion is probably the least of your concerns. And what can you do? Check errno after each and every system call? And what's the list of errno values we should consider? And how should we handle them? How likely is it to happen? What's the worst that can happen if it's not handled "properly"? Can that be exploited? Say you're the sysadmin that needs to fix that low kernel memory situation, it's probably better to keep your shell running as long as possible. That's a narrow ridge to walk on there. I agree that letting the user know of that pathological condition is useful, but we need to be careful the cure be not worse than the disease. In any case, I would imagine this kind of consideration has already been discussed at length here and elsewhere. In anycase, I'm no expert at all on that. -- Stephane