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

Re: The (e) glob qualifier and NO_NOMATCH

Bart wrote:
> 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*".

The main thing that makes (e) useful is that it runs the function once
for each matched file. forcemount presumably is something that only
needs to run once because the parameter you want to pass is an
unexpanded pattern.

Given that you can do something like:

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

is your point purely that you think the syntax would be nice or are you
thinking in terms of being able to pass the function down through the
completion system so that it is only run if and when _path_files expands
the pattern?

> don't seem to have the order-dependence that one might expect:
>   print *(e:'reply=(${REPLY}x)':/)

In many respects using (e) and modifying $reply makes it more of a
modifier than a qualifier. Perhaps we should have had a :e modifier.

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

You might also find it interesting to look at the trick I used in
_subversion for tricking globbing into generating files that don't
exist. It does the following:

  _files -g ".svn(/e:_svn_deletedfiles:)"

The use of .svn as the file is largely irrelevant. This works better
than the similar functionality in _cvs because the rest of
_file/_path_files is used). It isn't perfect due to the fact that the
fake files can't have type information associated with them.


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