Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

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