Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Incorrect evaluation of ~ test in ternary conditional
- X-seq: zsh-workers 42133
- From: Felix Uhl <felix.uhl@xxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Incorrect evaluation of ~ test in ternary conditional
- Date: Fri, 15 Dec 2017 13:55:03 +0000
- Accept-language: de-DE, en-US
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
- Thread-index: AQHTdaxOCnrC+8lS2UuLQjsbyOJJ9Q==
- Thread-topic: Incorrect evaluation of ~ test in ternary conditional
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author