Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
A bug or improperly formatted script
- X-seq: zsh-users 22495
- From: Jim <linux.tech.guy@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: A bug or improperly formatted script
- Date: Sat, 25 Feb 2017 12:34:16 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:from:date:message-id:subject:to; bh=zrKS6GnwJtHKdDZmeF+UEUPFWt/dLxG5F/Slr7pJJMw=; b=e/jggO0n4I0Dif10+B0cIXWrOx+F0Z7MGtYJQRIs1/GLhVLWGXIBzMZ/df13zxhB2I LBFAGnQqIZ25+70FLlIz9SvjHhZ+9+qliS9FwbdymFiHW5VUdlTLFuxHDL1R/0fcAcc+ Vk8tqnH1sQFYYRJ+kr5gQbeLFpTGjfVPrm3X17qu0l5WM3lNRSREoFVjZdArBVaS3WzB F3yh5FvWZ6NmI9e8cvCeRTrt/hnRRjicseGwdTIYRvig9PKWOKzq+HHtd1IvAE4rWJ6s ziJLneW2t188aM229/Hn934Ey3ePGx1UdA8vefBc1L/2sfWg3Y1HKT/E4p5KqwL1I2kx 2X7g==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Reply-to: linuxtechguy@xxxxxxxxx
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author