zsh-users
 help / color / mirror / code / Atom feed
* A bug or improperly formatted script
@ 2017-02-25 18:34 Jim
  2017-02-25 22:12 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Jim @ 2017-02-25 18:34 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]

ZSH_VERSION:  4.3.17, 5.0.8, 5.2, 5,3.1

While doing a search, unrelated, I found the following on the
zsh-lovers(1) man page:

# Count the number of directories on the stack
  $ print $((${${(z)${(f)"$(dirs -v)"}[-1]}[1]} + 1)) #...

I was surprised the first time I tried it I got "-2" as the output.

Modifying the script to

$ print $((${(z)${(fO)"$(dirs -v)"}[1][1]} + 1))

returned "1" as expected.  "dirs -v" outputs "0      ~".  Stripping the

expression from the original script, outputs, "~" whereas the modified

script returns "0".  It would appear as if the original script is returning

a scalar when the stack only has one entry and an array when the

stack has 2 or more entries.  Tested another, somewhat unrealistic,

case with a directory "-" under the home directory "0      ~/-", the

output was "-1" for the original script.

So, is this a bug, or scripting?  Hard to believe someone

hadn't run across something like this before.


Sincerely,

Jim

Sorry if this email looks strange, gmail, as least while composing,

looked really strange after a cut/paste dropped in some fixed font

and line spacing went nuts.

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

end of thread, other threads:[~2017-02-26  0:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-25 18:34 A bug or improperly formatted script Jim
2017-02-25 22:12 ` Bart Schaefer
2017-02-25 22:53   ` Jim
2017-02-25 23:41     ` Bart Schaefer
2017-02-26  0:58       ` Jim

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