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

Re: The (e) glob qualifier and NO_NOMATCH



Bart wrote:
> Rather I'm thinking in terms of the "search upwards but stop at the
> first file" glob request posted to zsh-users earlier this week.  I
> wanted to say
> 
>   up() { reply=( (../)#$~REPLY(Odon) ); reply=( $reply[1] ) }
> 
>   less adr*(+up)

The closest I can think of that you can get to this is something like
the following:
  up() { print -r "(../)#$1(Odon[1])" }
  alias up='noglob up'

  less ${~$(up adr*)}

That's not much easier to type but it might make more sense to allow
something like $~(up d*) to work than to add a glob qualifier that
alters the pattern.

In the case of the actual searching upwards problem, I've wondered in
the past whether some actual syntax would make sense. I mostly use it
for getting to Ant build.xml files and have considered using bindkey -s
so that something like '.**/' would expand to '(../)#'. A new syntax
could perhaps work a little differently than '(../)#' to avoid needing
(Odon[1]) or ([-1]). Stopping at the first directory that produces a
match is probably enough (searching up from .. to / not down from / to
..).

Oliver



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