zsh-workers
 help / color / mirror / code / Atom feed
* 3.1.9-dev-6: bug or confusion?
@ 2000-09-13 18:44 E. Jay Berkenbilt
  2000-09-14  4:57 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: E. Jay Berkenbilt @ 2000-09-13 18:44 UTC (permalink / raw)
  To: zsh-workers


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@ql.org)  |  http://www.ql.org/q/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-09-14  4:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-13 18:44 3.1.9-dev-6: bug or confusion? E. Jay Berkenbilt
2000-09-14  4:57 ` Bart Schaefer

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).