From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Inconsistency of GLOB_ASSIGN
Date: Thu, 27 Nov 2014 13:38:33 -0800 [thread overview]
Message-ID: <141127133833.ZM6853@torch.brasslantern.com> (raw)
In-Reply-To: <20141127204349.036d3807@pws-pc.ntlworld.com>
On Nov 27, 8:43pm, Peter Stephenson wrote:
} Subject: Re: Inconsistency of GLOB_ASSIGN
}
} It would be neater always to do an array assignment, in fact, but
} the traditional behaviour is that if there was only one result the
} assignment is scalar, and GLOB_ASSIGN is really there only for
} tradition.
That's too bad, because making it always be an array assignment is a
lot simpler than figuring out whether the glob expanded to something.
(I think. Still pondering.)
There are also very few contexts where a single-element array and
a scalar behave differently. The only one I can think of would be
subscript slices, but if you're glob-assigning to a variable and then
expecting to be able to subscript it as a string, you're already in
pretty strange territory.
One interesting thing is what happens with NO_NOMATCH. A failed glob
still returns a single-element array in that case, whereas a string
containing no globbing characters is a scalar.
} Arguably we should look at the type of the destination and if it's
} numeric not do a glob at all. I'd be happy with that, since:
}
} integer x
} x=3*3
}
} probably doesn't mean "look for files beginning and ending in 3"
The "happy" behavior is already the case for NO_GLOB_ASSIGN, so I
think it's OK to ignore the type of the variable when the value is
asserted to be a glob.
next prev parent reply other threads:[~2014-11-27 21:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-27 5:57 Bart Schaefer
2014-11-27 20:43 ` Peter Stephenson
2014-11-27 20:51 ` Bart Schaefer
2014-11-27 21:38 ` Bart Schaefer [this message]
2014-11-27 23:00 ` Bart Schaefer
2014-11-28 9:34 ` Peter Stephenson
2014-11-28 18:39 ` Bart Schaefer
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=141127133833.ZM6853@torch.brasslantern.com \
--to=schaefer@brasslantern.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).