From: Felix Uhl <felix.uhl@outlook.de>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Incorrect evaluation of ~ test in ternary conditional
Date: Fri, 15 Dec 2017 13:55:03 +0000 [thread overview]
Message-ID: <DB6P194MB0037AE570D0106FB365F3C549D0B0@DB6P194MB0037.EURP194.PROD.OUTLOOK.COM> (raw)
Hi everybody!
Let there be a directory ~/work. Using the ~ test character in a
conditional ternary prompt will return incorrect results when the
argument is 2 as shown below:
$ cd && print -P "%(2~:true:false)"
false
$ cd work/.. && print -P "%(2~:true:false)"
true
The docs say:
(http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Conditional-Substrings-in-Prompts)
> c [...] . [...] ~ [...] True if the current path, with prefix
replacement, has at least n elements relative to the root directory,
hence / is counted as 0 elements.
So the first command behaves properly, but the second one doesn't.
I'm using zsh 5.0.5. Can somebody confirm this for the current version
of zsh as well?
BR, Felix
next reply other threads:[~2017-12-15 13:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-15 13:55 Felix Uhl [this message]
2017-12-16 22:01 ` Bart Schaefer
2017-12-18 15:07 ` Felix Uhl
2017-12-30 2:40 ` Bart Schaefer
2018-01-03 10:44 ` Felix Uhl
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=DB6P194MB0037AE570D0106FB365F3C549D0B0@DB6P194MB0037.EURP194.PROD.OUTLOOK.COM \
--to=felix.uhl@outlook.de \
--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).