Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: $(<nofile) doesn't set $? to non-zero
- X-seq: zsh-workers 42460
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: $(<nofile) doesn't set $? to non-zero
- Date: Wed, 14 Mar 2018 11:04:50 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=NzvTp4/+8+p6LxRseG2F9DewvBtjscYidQ3L5RxF1nM=; b=cgWkOit7fxfVCiuecH/p7oTCfQBSqJq+2rwK0W/mSU9JzI9bU501x9j23K8lT7FkzQ tsW93+uYgLdVEyFRu07/L3AxWM03EJFUuRGx4qx/tXAmAtE3mZuYyDyffyxV8R9v9qH3 UsQSUk/EibO7GIfoQJ7HwYOpeSmTDSC299hQIXvoMSjptiLZcx1Ja4VpRkUWX4978OZd +3AhokHDNOxT7k0synIEK3V9kMzPZNJ53zP1sU2qo21mbNYbJDnGm/T/P46RsYCegY3w mNog16oW5Bt4v/fDcFZz8U8lzNMM24fqXyXsiYOvzYi+HrKxSv/ID6jDIZK/4zq+t6k3 AG9g==
- In-reply-to: <20180314103254.GA10404@chaz.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180314103254.GA10404@chaz.gmail.com>
2018-03-14 10:32:54 +0000, Stephane Chazelas:
[...]
> Note that all shells are silent and return 0 for var=$(</etc)
> var=$(</dev/mem) or any file that can be opened but not read
> successfully, which IMO is not ideal.
[...]
In zsh, one can use $ERRNO though:
$ zsh -c 'zmodload zsh/system; ERRNO=0; var=$(</); echo $? $ERRNO; syserror'
0 21
Is a directory
$ zsh -c 'zmodload zsh/system; ERRNO=0; var=$(<file); echo $? $ERRNO; syserror'
zsh:1: no such file or directory: file
0 2
No such file or directory
(same for $mapfile[file] which is silent on errors).
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author