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

Re: Order of modifiers and flags in parameter expansion



Hannu Koivisto wrote:
> I have a script foo-files that prints filenames separated by
> newlines.  I want directory parts of those filenames and then I
> want to get rid of duplicates.  So I write
> ${(u)${(f)"$(foo-files)"}:h} which works and the fact that it works
> means that the h modifier is applied before the u flag.
> Unfortunately I can't find where in the manual this order is
> specified.  I have read 13.3.2 but it didn't seem to consider the u
> flag even indirectly.  Any clues?

It does happen in that order, but it's not currently documented.

Index: Doc/Zsh/expn.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v
retrieving revision 1.51
diff -u -r1.51 expn.yo
--- Doc/Zsh/expn.yo	22 Feb 2005 18:24:38 -0000	1.51
+++ Doc/Zsh/expn.yo	18 Mar 2005 11:05:29 -0000
@@ -973,16 +973,24 @@
 occurrences of any of the characters in tt($IFS).  Note this step, too,
 takes place at all levels of a nested substitution.
 )
-item(tt(10.) em(Re-Evaluation))(
+item(tt(10.) em(Uniqueness))(
+If the result is an array and the `tt((u))' flag was present, duplicate
+elements are removed from the array.
+)
+item(tt(11.) em(Ordering))(
+If the result is still an array and one of the `tt((o))' or `tt((O))' flags
+was present, the array is reordered.
+)
+item(tt(12.) em(Re-Evaluation))(
 Any `tt((e))' flag is applied to the value, forcing it to be re-examined
 for new parameter substitutions, but also for command and arithmetic
 substitutions.
 )
-item(tt(11.) em(Padding))(
+item(tt(13.) em(Padding))(
 Any padding of the value by the `tt(LPAR()l.)var(fill)tt(.RPAR())' or
 `tt(LPAR()r.)var(fill)tt(.RPAR())' flags is applied.
 )
-item(tt(12.) em(Semantic Joining))(
+item(tt(14.) em(Semantic Joining))(
 In contexts where expansion semantics requires a single word to
 result, all words are rejoined with the first character of tt(IFS)
 between.  So in `tt(${LPAR()P)tt(RPAR()${LPAR()f)tt(RPAR()lines}})'

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


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************



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