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

Re: aliases not getting expanded inside functions?



Phil Pennock (Phil.Pennock@xxxxxxxxxxx) wrote on 3 January 2003 18:44:
 >print is merely what was used for showing the results.  The variable
 >substitution does not rely upon print.

I agree, I just used print as an example of reading the value, not
setting it.

 >% set -A array alpha beta gamma delta epsilon zeta
 >% guess_what='array[3]'
 >% echo ${(P)guess_what}
 >gamma
 >% guess_what='array[4]'
 >% echo ${(P)guess_what}
 >delta

It doesn't work if you try to do guess_what=foobar, meaning
array[4]=foobar.

 >% guess_what='array[1]'
 >% for i in $(perl -le "print foreach split //, '${(P)guess_what}'") ; echo $i
 >a
 >l
 >p
 >h
 >a
 >%

Nice :-) I should have learned perl long since. In fact probably the
script I'm doing should be written in perl...

 >I think that you're confusing "print -P", which recognises the same
 >escape sequences as are used in prompt substitution, with the parameter
 >expansion flag 'P', which is described in zshexpn(1).

The manual says "Recognize the same escape sequences as the print
builtin in string arguments to subsequent flags." So there should be a
relation.



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