Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
3.1.9-dev-6: bug or confusion?
- X-seq: zsh-workers 12799
- From: "E. Jay Berkenbilt" <ejb@xxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: 3.1.9-dev-6: bug or confusion?
- Date: Wed, 13 Sep 2000 14:44:41 -0400
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Define these two functions:
function okay
{
emulate -L zsh
echo ${#${@:#-}}
setopt localoptions xtrace
(( ${#${@:#-}} ))
}
function broken
{
emulate -L zsh
echo ${#${@#-}}
setopt localoptions xtrace
(( ${#${@#-}} ))
}
Notice that the only difference between these two functions is that
one uses :# (match whole word) and the other uses # (match beginning
of word) as applied to each element of $@.
Then run
zsh% okay -
You get the expected output:
0
+okay:5> (( 0 ))
Now run
zsh% broken -
You get the unexpected (by me anyway) output:
0
+broken:5> (( 1 ))
Why would the value be 1 inside (( ... )) and 0 outside in the second
case but not in the first? Does it have something to do with an empty
string being counted as a word in one case but not the other? Is it a
bug? If not, I'd be grateful if someone could explain this behavior.
--
E. Jay Berkenbilt (ejb@xxxxxx) | http://www.ql.org/q/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author