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

Re: Baffling bug with ${(S)...} or ${...//p/r} and math context



"Bart Schaefer" wrote:
> Now here's the strange bit:  If I use that in a math expression (( ... )),
> it gives the correct number, and the inequality evaluates correctly:
> 
> 	((${#${(f)${(%%)${(S)PS1//[%]\{*%\}/}}}[1]} > COLUMNS-2))
> 
> However, if I immediately evaluate the same expression again, the answer
> is different!  E.g., if I do
> 
> 	print ${#${(f)${(%%)${(S)PS1//[%]\{*%\}/}}}[1]}
> 	    ((${#${(f)${(%%)${(S)PS1//[%]\{*%\}/}}}[1]} > COLUMNS-2))
> 	print ${#${(f)${(%%)${(S)PS1//[%]\{*%\}/}}}[1]}
> 
> I'm likely to get
> 
> 	77
> 	86
> 
> as the output.

Hmm, it wouldn't be something to do with the fact that the length of the
output, even excluding %{...%}'s, varies with the status of the previous
command, by any chance?

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk



Messages sorted by: Reverse Date, Date, Thread, Author