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

Re: Some problems with recursive globbing



On Thu, 7 May 2015 18:46:58 +0200
Jesper Nygårds <jesper.nygards@xxxxxxxxx> wrote:
> I tried this:
> myfiles() {
>     emulate -L zsh
>     setopt LOCAL_OPTIONS EXTENDED_GLOB
> 
>     local dir="${1:a}/"
> 
>     local filepattern="${dir}**/*"
> 
>     print -c ${~filepattern}
> }
> 
> % cd /private/tmp/test\(1\)
> % myfiles src
> myfiles:8: no matches found: /private/tmp/test(1)/src/**/*

$dir contains a straight string with unquoted parentheses.  The
~filepattern then turns those parentheses into pattern characters.

I'm not sure why you want filepattern anyway, but

print -c ${dir}**/*

or

local filepattern="**/*"
print -c ${dir}${~filepattern}

ought to work.  Otherwise you'll need to quote metacharacters in dir,
which is possible but should be unnecessary.

pws



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