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

Problem with glob qualifier e



Greetings,

The manual of zsh 4.2.1 says the following about the glob qualifier
e:

     filename.  In addition, the parameter reply may be set to an array
     or a string, which overrides the value of REPLY.  If set to an
     array, the latter is inserted into the command line word by word.

     For example, suppose a directory contains a single file
     `lonely'.  Then the expression `*(e:'reply=(${REPLY}{1,2})':)'
     will cause the words `lonely1 lonely2' to be inserted into the
     command line.

I can verify that the example works as described.  But I don't
understand how to extend that to more complex cases.

For instance, let's say that I would like to splice two command
line arguments after each file argument produced by a glob pattern.
If I have files sur and pur in the current directory, I would like
to say something along the lines of

echo (sur|pur)(e:'<something>':)

which, when expanded, should result to

echo pur -foo bar sur -foo bar

I expected

echo (sur|pur)(e:'reply=(${REPLY} -foo bar)':)

to do what I want but instead that results to

echo -foo -foo bar bar pur sur

I can't see how that follows from the quoted documentation.  In any
case, if my goal cannot be achieved with the glob qualifier e, is
there some other brief trick to modify the list of generated
filenames in such a way?

-- 
Hannu



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