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

Re: breadth first globbing



On Tue, Mar 31, 2015 at 12:42 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Mar 31, 2015 3:05 AM, "Mikael Magnusson" <mikachu@xxxxxxxxx> wrote:
>>
>> On Tue, Mar 31, 2015 at 11:44 AM, Helmut Jarausch
>> <jarausch@xxxxxxxxxxxxxxxxxxx> wrote:
>> >
>> > I have (unpacked) a directory tree where directories don't have the
>> > executable bit.
>> >
>> > Standard globbing like  **/*(/) doesn't work because zsh tries to cd to
>> > the directories
>> > before I can chmod +x these.
>> >
>>
>> I would probably just chmod -R +x followed by chmod -x **/*(.)
>
> Breadth-first globbing is **/*(/Od)
> but in this case the problem is that globbing itself can't match anything
> until the directory modes have changed, I think?
>
> So I'd just do something like
>
> while chmod +x **/*(/^x); do :; done
>
> Assuming you have nomatch set so the loop will fail when all directories
> have the x mode.

Another possibility is
: **/*(/e:chmod +x \$REPLY:)
But it will run very slowly if there are a large number of directories
(one fork per directory).

-- 
Mikael Magnusson



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