Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Somewhat unexpected results of {myfd}>&1 when noclobber set
- X-seq: zsh-workers 31129
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Somewhat unexpected results of {myfd}>&1 when noclobber set
- Date: Sat, 9 Mar 2013 11:33:38 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=fiHTuQHzANr2Bh5+1mVB/RQkAEINkFTgIWwxwUXU9xU=; b=J6OJ6Pm/V9KV/VnbpZ58dc2F8uVgw72k0zHHhkQSpIrvdVhySqZJQyhZp4lrmt03F+ lgnL69UbGcpJPqkkHOAuHt98+DL759IWffO2VSEy/9vQBrEx0XGOZGSA+jOKGPWaSY+t 0C2u3vWw874ikOmZcsAP+YP8I4E54qQ0dzdqY8+kdjwgrcSZtyA8SBblZ4Yc2tIcSeXn ZrXXWRNtJCQwsUEymSVMVBbKQ3R3c6h8RY+eUL3febfSYZCfWw71VRRD+5lMZ2QQYCxZ cy8JrgW8d9PoUkriUgSIevnO7MERGv4sAqs6ehV6mPF6OBFR3AdvukJTmCXFDwK83Hu0 urtw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
(You can skip this most of this part, just included some variations for fun)
% setopt noclobber
% : {foo}>&1
% echo $foo
15
% bar=7+8
% : {bar}>&1
zsh: can't clobber parameter bar containing file descriptor 15
% bar=foo
% : {bar}>&1
zsh: can't clobber parameter bar containing file descriptor 15
% bar=( 14 15 )
% : {bar}>&1
zsh: bad math expression: operator expected at `15'
% echo $bar
16
% bar=foo
% : {bar}>&1
zsh: can't clobber parameter bar containing file descriptor 15
% foo=
% : {bar}>&1
zsh: can't clobber parameter bar containing file descriptor 15
% echo $bar
15
(at this point bar somehow became of type "integer", i think after it
was an array, so the earlier assignment bar=foo resolved foo to 15).
Of course, all these are the result of the fact that when the
clobbering is checked, the parameter name is passed to getintvalue()
which does mathevali() on the contents (possibly after joining if it
was an array). Should we perhaps instead explicitly check that the
parameter is a) a scalar b) just do atoi() or whichever function is
best for this, and compare directly?
I think it's at least not expected that this parameter is only subject
to math evaluation if the clobber option is unset.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author