zsh-workers
 help / color / mirror / code / Atom feed
* Incorrect evaluation of ~ test in ternary conditional
@ 2017-12-15 13:55 Felix Uhl
  2017-12-16 22:01 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Felix Uhl @ 2017-12-15 13:55 UTC (permalink / raw)
  To: zsh-workers

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


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

end of thread, other threads:[~2018-01-03 10:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-15 13:55 Incorrect evaluation of ~ test in ternary conditional Felix Uhl
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

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