zsh-users
 help / color / mirror / code / Atom feed
* breadth first globbing
@ 2015-03-31  9:44 Helmut Jarausch
  2015-03-31 10:04 ` Mikael Magnusson
  0 siblings, 1 reply; 6+ messages in thread
From: Helmut Jarausch @ 2015-03-31  9:44 UTC (permalink / raw)
  To: zsh-users

Hi,

I have (unpacked) a directory tree where directories don't have the executable bit.
So, I want to iterate over all directories and set the executable bit.

Standard globbing like  **/*(/) doesn't work because zsh tries to cd to the directories
before I can chmod +x these.

Is there a solution with zsh or is it easier to write a Python script for that.

Many thanks for a hint,
Helmut



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: breadth first globbing
  2015-03-31  9:44 breadth first globbing Helmut Jarausch
@ 2015-03-31 10:04 ` Mikael Magnusson
  2015-03-31 10:42   ` Bart Schaefer
  2015-03-31 10:53   ` Michal Politowski
  0 siblings, 2 replies; 6+ messages in thread
From: Mikael Magnusson @ 2015-03-31 10:04 UTC (permalink / raw)
  To: jarausch; +Cc: Zsh Users

On Tue, Mar 31, 2015 at 11:44 AM, Helmut Jarausch
<jarausch@igpm.rwth-aachen.de> wrote:
> Hi,
>
> I have (unpacked) a directory tree where directories don't have the executable bit.
> So, I want to iterate over all directories and set the executable bit.
>
> Standard globbing like  **/*(/) doesn't work because zsh tries to cd to the directories
> before I can chmod +x these.
>
> Is there a solution with zsh or is it easier to write a Python script for that.
>
> Many thanks for a hint,
> Helmut

I would probably just chmod -R +x followed by chmod -x **/*(.), that's
assuming you don't have a mix of +x and -x files already though.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: breadth first globbing
  2015-03-31 10:04 ` Mikael Magnusson
@ 2015-03-31 10:42   ` Bart Schaefer
  2015-03-31 12:10     ` Mikael Magnusson
  2015-03-31 10:53   ` Michal Politowski
  1 sibling, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2015-03-31 10:42 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Zsh Users, jarausch

[-- Attachment #1: Type: text/plain, Size: 777 bytes --]

On Mar 31, 2015 3:05 AM, "Mikael Magnusson" <mikachu@gmail.com> wrote:
>
> On Tue, Mar 31, 2015 at 11:44 AM, Helmut Jarausch
> <jarausch@igpm.rwth-aachen.de> 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: breadth first globbing
  2015-03-31 10:04 ` Mikael Magnusson
  2015-03-31 10:42   ` Bart Schaefer
@ 2015-03-31 10:53   ` Michal Politowski
  1 sibling, 0 replies; 6+ messages in thread
From: Michal Politowski @ 2015-03-31 10:53 UTC (permalink / raw)
  To: Zsh Users

On Tue, 31 Mar 2015 12:04:37 +0200, Mikael Magnusson wrote:
> On Tue, Mar 31, 2015 at 11:44 AM, Helmut Jarausch
> <jarausch@igpm.rwth-aachen.de> wrote:
> > Hi,
> >
> > I have (unpacked) a directory tree where directories don't have the executable bit.
> > So, I want to iterate over all directories and set the executable bit.
> >
> > Standard globbing like  **/*(/) doesn't work because zsh tries to cd to the directories
> > before I can chmod +x these.
> >
> > Is there a solution with zsh or is it easier to write a Python script for that.
> >
> > Many thanks for a hint,
> > Helmut
> 
> I would probably just chmod -R +x followed by chmod -x **/*(.), that's
> assuming you don't have a mix of +x and -x files already though.

Even simpler should be chmod -R +X (with a capital 'X')

-- 
Michał Politowski
Talking has been known to lead to communication if practiced carelessly.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: breadth first globbing
  2015-03-31 10:42   ` Bart Schaefer
@ 2015-03-31 12:10     ` Mikael Magnusson
  0 siblings, 0 replies; 6+ messages in thread
From: Mikael Magnusson @ 2015-03-31 12:10 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users, jarausch

On Tue, Mar 31, 2015 at 12:42 PM, Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> On Mar 31, 2015 3:05 AM, "Mikael Magnusson" <mikachu@gmail.com> wrote:
>>
>> On Tue, Mar 31, 2015 at 11:44 AM, Helmut Jarausch
>> <jarausch@igpm.rwth-aachen.de> 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* breadth first globbing
@ 2015-03-31  9:32 Helmut Jarausch
  0 siblings, 0 replies; 6+ messages in thread
From: Helmut Jarausch @ 2015-03-31  9:32 UTC (permalink / raw)
  To: zsh-users

Hi,

I have (unpacked) a directory tree where directories don't have the executable bit.
So, I want to iterate over all directories and set the executable bit.

Standard globbing like  **/*(/) doesn't work because zsh tries to cd to the directories
before I can chmod +x these.

Is there a solution with zsh or is it easier to write a Python script for that.

Many thanks for a hint,
Helmut



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-03-31 12:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-31  9:44 breadth first globbing Helmut Jarausch
2015-03-31 10:04 ` Mikael Magnusson
2015-03-31 10:42   ` Bart Schaefer
2015-03-31 12:10     ` Mikael Magnusson
2015-03-31 10:53   ` Michal Politowski
  -- strict thread matches above, loose matches on Subject: below --
2015-03-31  9:32 Helmut Jarausch

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).