Forum: Ruby Ruby equivalent to `find . -perm -g+rw -ls`

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1101fee96cbaa23a1d4ec3322b994fff?d=identicon&s=25 Bil Kleb (Guest)
on 2008-11-17 15:25
(Received via mailing list)
Hi,

I can't find a Ruby equivalent to

  find . -perm -g+rw -ls

Currently, it looks like I'll need to combine,

  File.stat(file).mode

with something like Hal Fulton's sym2oct,

  http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...

hacked into Daniel Berger's file-find gem,

 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...

and require 'etc' to pull out the user and group names instead of uids
and gids?

Is there an alternative to all this yak shaving?

Thanks,
79caabff3b239b1bee6de8c51bc7f78c?d=identicon&s=25 Rolando Abarca (Guest)
on 2008-11-17 16:24
(Received via mailing list)
On Nov 17, 2008, at 11:21 AM, Bil Kleb wrote:

> with something like Hal Fulton's sym2oct,
> Is there an alternative to all this yak shaving?
maybe something like this?

rolando:test_perm rolando$ ls -l
total 8
-rw-rw-r--  1 rolando  staff   0 Nov 17 12:12 1
-rw-r--r--  1 rolando  staff   0 Nov 17 12:13 2
-rw-r--r--  1 rolando  staff  77 Nov 17 12:21 perm.rb

rolando:test_perm rolando$ find . -perm -g+rw -ls
1510804        0 -rw-rw-r--    1 rolando  staff           0 Nov 17
12:12 ./1

rolando:test_perm rolando$ ruby perm.rb
["./1"]
rolando:test_perm rolando$ cat perm.rb
# NOTE: 060 == g+rw
p Dir["./**/*"].select { |f| File.stat(f).mode & 060 == 060 ? true :
nil }


> Thanks,
> --
> http://twitter.com/bil_kleb


regards,
1101fee96cbaa23a1d4ec3322b994fff?d=identicon&s=25 Bil Kleb (Guest)
on 2008-11-17 19:35
(Received via mailing list)
Hi,

Rolando Abarca <funkas...@gmail.com> wrote:
>
> maybe something like this?
> [..]
> rolando:test_perm rolando$ cat perm.rb
> # NOTE: 060 == g+rw

This is what I'm reduced to doing now.  It just feels wrong
for me to have to resort to octal -- it's not at the
correct abstraction level as evidenced by your comment.

> p Dir["./**/*"].select {
>  |f| File.stat(f).mode & 060 == 060 ? true : nil }

You don't need the '? true : nil' part AFAICT -- the
first conditional satisfies select.

Regards,
Aee77dba395ece0a04c688b05b07cd63?d=identicon&s=25 Daniel Berger (djberg96)
on 2008-11-17 19:44
(Received via mailing list)
Bil Kleb wrote:
> with something like Hal Fulton's sym2oct,
> Is there an alternative to all this yak shaving?
Not at the moment, but both are excellent ideas. I've submitted them
myself at:

http://rubyforge.org/tracker/index.php?func=detail...
http://rubyforge.org/tracker/index.php?func=detail...

Supporting strings for users and groups is trivial. Supporting symbolic
permissions will be more of a hassle.

Regards,

Dan
79caabff3b239b1bee6de8c51bc7f78c?d=identicon&s=25 Rolando Abarca (Guest)
on 2008-11-17 19:44
(Received via mailing list)
On Nov 17, 2008, at 3:31 PM, Bil Kleb wrote:

> You don't need the '? true : nil' part AFAICT -- the
> first conditional satisfies select.

that's correct.

> Regards,
> --
> http://twitter.com/bil_kleb


regards,
1101fee96cbaa23a1d4ec3322b994fff?d=identicon&s=25 Bil Kleb (Guest)
on 2008-11-17 20:00
(Received via mailing list)
Hi,

Daniel Berger <djber...@gmail.com> wrote:
> Bil Kleb wrote:
> > [..] Is there an alternative to all this yak shaving?
>
> Not at the moment, but both are excellent ideas.
> I've submitted them myself at:
>
> [http://rubyforge.org/tracker/?atid=2912&group_id=735]

Excellent; thanks.

Regards,
Aee77dba395ece0a04c688b05b07cd63?d=identicon&s=25 Daniel Berger (djberg96)
on 2008-11-18 00:51
(Received via mailing list)
Bil Kleb wrote:
> Excellent; thanks.
I've already tested and committed the changes for the :user and :group
changes.
They'll be part of release 0.2.2. I should have a release out this week.

I'll save the :perm changes for 0.2.3 after I've had the chance to
review some
of the code I've seen online.

Regards,

Dan
Aee77dba395ece0a04c688b05b07cd63?d=identicon&s=25 Daniel Berger (djberg96)
on 2008-11-19 18:32
(Received via mailing list)
Hi,

On Nov 17, 11:56 am, Bil Kleb <Bil.K...@gmail.com> wrote:
>
> Excellent; thanks.

file-find 0.2.2 has been released, which now supports names as well as
id's for the :name and :group options (on Unix, anyway).

Regards,

Dan
Aee77dba395ece0a04c688b05b07cd63?d=identicon&s=25 Daniel Berger (djberg96)
on 2008-12-11 00:34
(Received via mailing list)
On Nov 17, 7:21 am, Bil Kleb <Bil.K...@gmail.com> wrote:
> with something like Hal Fulton's sym2oct,
> Is there an alternative to all this yak shaving?
I just released file-find 0.2.4 which now does all your yak shaving
for you, i.e. it now supports symbolic permissions, too.

Regards,

Dan
This topic is locked and can not be replied to.