Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Some problems with recursive globbing
- X-seq: zsh-users 20194
- From: Jesper Nygårds <jesper.nygards@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Some problems with recursive globbing
- Date: Fri, 8 May 2015 05:37:59 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Ekiyt/zLhZ1OqekZavzRn7+ymNFXN2LCAn4t7FkwUpo=; b=gxL9L1FnKLHTXXRxxSfGOhtc2cgnVf6qZE6W6N1ZD7J5d27yaJcmUuu49qD7gP62O/ Y2snv49md58FooNfJHhSSOqxqXL9Og7sHx+ZW3Xh8TEPhFB6TVgHujHH/WS0AUY6YNcN R2Fecdfbwo0tjKwZBrvoZPtxic6WMpytbh1QRhR6tPodCci6WTab9mE0AK46RGmZBm1C QNXVccCExYC/i8oYVg2JyKjy77KMTzV9lPW6sFhL9NyTf4JuCwUAeVPZHcmGnBjJATmQ Fh44Ee8F55Gh2UskRXEe/wfpFidi0/d580T5s+4pxiU1XHfk2A2q1WiHDDOHJ+cLuUWx JdNA==
- In-reply-to: <CABZhJg8xzCNeTNRks2HV8AXTe_Vj9Sf=N3wrOg--kG+uwZWuwg@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CABZhJg-f_PDTtaJf8Fg6qVZQ2wLmAXG-tLXLub7Sq=GW9vXwDA@mail.gmail.com> <20150507165250.18184e1a@pwslap01u.europe.root.pri> <20150507165953.517b95b9@pwslap01u.europe.root.pri> <CABZhJg_2uhT-c1Gn+e+=ng3o4L=P8LJRZukjF3T7LqwiGL1OHQ@mail.gmail.com> <20150507180045.0afc79fd@pwslap01u.europe.root.pri> <CABZhJg8xzCNeTNRks2HV8AXTe_Vj9Sf=N3wrOg--kG+uwZWuwg@mail.gmail.com>
I found a solution to my particular problem. I can quote the dir, and then
remove the quoting of the spaces afterwards.
myfiles() {
emulate -L zsh
setopt LOCAL_OPTIONS EXTENDED_GLOB
local dir="${(q)1:a}/"
dir=${dir/\\\ / }
local filepattern="${dir}**/*"
print -c ${~filepattern}
}
I realize this could brake on even more exotic file names, but for now I'm
happy with this solution.
On Thu, May 7, 2015 at 7:21 PM, Jesper Nygårds <jesper.nygards@xxxxxxxxx>
wrote:
> On Thu, May 7, 2015 at 7:00 PM, Peter Stephenson <p.stephenson@xxxxxxxxxxx
> > wrote:
>
>> $dir contains a straight string with unquoted parentheses. The
>> ~filepattern then turns those parentheses into pattern characters.
>>
>> Yes, I understand.
>
>
>> I'm not sure why you want filepattern anyway, but
>>
>> I tried to simplify my function to make my problem obvious. In my "real"
> function, I am collecting several function arguments into a combined
> pattern, which is why I need to use this indirect method.
>
> 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.
>>
>
> Yes, but as my second example demonstrates: if I quote my filepattern, it
> then doesn't work for files with spaces in their names. I was hoping for a
> solution where it would be possible to get this to work for both situations.
>
>
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author