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

Re: check for existence without full globbing



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?

It can be done, but it requires forking a subshell, which may not make
it any faster than just generating the list of files to begin with:

if ( : *(Ne:exit 0:) ; exit 1 )
then
  print There are some files in this directory
else
  print There are no files in this directory
fi



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