zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Somewhat unexpected results of {myfd}>&1 when noclobber set
Date: Sat, 9 Mar 2013 11:33:38 +0100	[thread overview]
Message-ID: <CAHYJk3SexAxWnKHSBWCnvcAu7RjC_Go6Sd1Uwn-QujvpYzrnvw@mail.gmail.com> (raw)

(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


             reply	other threads:[~2013-03-09 10:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-09 10:33 Mikael Magnusson [this message]
2013-03-09 15:12 ` Bart Schaefer
2013-03-10 12:11   ` Mikael Magnusson
2013-03-10 18:26     ` Bart Schaefer
2013-03-10 18:52   ` Peter Stephenson
2013-03-10 20:17     ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHYJk3SexAxWnKHSBWCnvcAu7RjC_Go6Sd1Uwn-QujvpYzrnvw@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).