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

Re: check for existence without full globbing



 --- Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote: > On Feb 3,  4:24pm, Le
Wang wrote:
> } 
> } I wonder if there is a way to check if a glob pattern can be matched
> } without getting all files that can be globbed, i.e. a function that
> } return true after the first match is found.
> 
> Out of curiosity, why?

I need to get a list of directories that have .java files in them.  Here is
the snipplet:

for i ( $sourcePath ) {
  for j ( $i/**/*(-/) ) {
    setopt localoptions
    setopt nullglob
    unsetopt globsubst
    tempArr=( $j/*.java )

    if (( $#tempArr >= 1 )); then
      temp=${j#$i/}
      temp=${temp//\\//.}
      packages=( $packages $temp )
    fi
  }
}

It was taking quite a while to glob through all the .java files.  But it was
even slower to use the subshell method (like you suspected).  Ohh well.

--
Le

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca



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