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

Re: Parameter expansion flag (%) priority.



Frank Terbeck wrote:
> [snip]
> zsh% print ${(%):-%n}  
> hawk
> zsh% print ${(U%):-%n} 
> zsh
> zsh% print ${(%):-%N} 
> zsh
> [snap]
> 
> However, the docs say:
> 
> [snip]
>     U      Convert all letters in the result to upper case.
> [snap]
> 
> The 'letters in the result' led me to the assumption, that (U) would
> be applied *after* prompt expansion is done be (%).
> (Same applies to (L).)

Unfortunately parameter expansion does a zillion different things,
defined by the order they happen to occur in the code, so the description
"the result" is never going to be very helpful.  Some order dependence
is documented and this probably ought to be.

> (Background is, that someone on IRC asked for a way to lowercase the
>  '%m' replace in the his PS1. Our proposal of %{(%L):-%n} turned out
>  to be broken.)

That's actually easy:  ${(L):-${(%):-%n}} (or %m if that's what you
meant).  This is fully guaranteed against programmers' whims.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


.



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