Subject: Re: [PATCH] typeset: set $? on incidental error
From: Vincent Lefevre <[email-masked]>
To: [email-masked]
Date: Thu, 21 Jan 2016 15:22:01 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On 2016-01-20 07:47:52 +0000, Daniel Shahaf wrote:
> In real-life examples, if the command subst had a non-zero exit status,
> the value would typically _not_ be the one I asked for:
> 
>     % cd $(mktemp -d)
>     % local mtime=$(zstat +mtime myfile)
>     zstat: myfile: no such file or directory

This is not specific to "local". Same expected behavior with "printf":

cventin% local mtime=$(zstat +mtime myfile)
zsh: command not found: zstat
cventin% echo $?
0
cventin% printf "%s\n" $(zstat +mtime myfile)
zsh: command not found: zstat

cventin% echo $?
0

-- 
Vincent Lefèvre <[email-masked]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)