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

The (e) glob qualifier and NO_NOMATCH



It occurs to me that, unlike most of the other glob qualifiers, (e:cmd:)
doesn't necessarily need any existing filename on which to operate.

Consider by comparison _path_files in the completion code, which includes
a hack to force auto-mounting.  Wouldn't it be nice to be able to write a
function "forcemount" that matches a pattern against /etc/hosts or NIS
and mounts all those filesystems?  Then you could use

  for remote in /net/r*(+forcemount); do ...

This currently doesn't work, because once "r*" fails to match anything
in /net, the qualifiers are ignored and the entire string is returned as
the result.  Instead we'd need to call "forcemount" with REPLY set to
the path segment pattern "r*".

Unfortunately it looks like this would need a pretty large reworking of
the globbing code.  The original source string of path segment patterns
isn't kept around anywhere that I immediately see, and NO_NOMATCH is
handled only after the entire scan has completed.  Further, qualifiers
don't seem to have the order-dependence that one might expect:

  print *(e:'reply=(${REPLY}x)':/)

first finds all directories and then appends "x" to their names, rather
than failing entirely because there are no directories having the names
that result after appending an x to an existing name, and

  print *(e:'reply=(${REPLY}x)':e:'reply=(${REPLY}y)':)

does not produce names with "xy" appended, only with "y".

For the time being, I guess this is just food for thought.

-- 



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