On Tuesday, Nov 26, 2002, at 11:36 Europe/London, Tatsuhiko Miyagawa
wrote:
>BTW, why not including a executable script to replace/usr/bin/find in
>File::Find::Rule distribution?
>
> % findrule -type file -mp3 title="youth gone wild" -mp3 length="3min"/mp3
> % findrule -md5 blahblahblah/archives
> % findrule -type file -image_x 120
It's a good idea, so I started on one yesterday[1]. Unfortunately I
quickly hit on a problem of how to group without splitting arguments in
a way that wouldn't be ideal.
What I currently have is something that works like so:
% findrule file name [ red blue ]
# files called red or blue, below the current directory
% findrule file name red blue
# files called red, below the directory called blue
But it kindof expects you to know what takes arguments (like name) and
what doesn't (like file), which I'm not sure is so great. There's
possibly adding - to indicate that you mean a clause, but then what if
you really want to pass something starting with - as an argument. Hmmm.
% findrule -file -name red blue
# files called red or blue, below the current directory
% findrule -file -name red -- blue
# files called red, below the directory called blue
% findrule -file -name -name
# syntax error? I really wanted files called -name
I'm more just thinking out loud right now, but if you have any
suggestions I'd be glad to steal them from you.
Thanks
[1] http://mirth.unixbeard.net/svn/richardc/perl/File-Find-Rule/findrule
--
Rich ard Clamp <richardc@unixbeard.net>
PPT (Score:1)
I guess if you're building a workalike for unix find, you should follow the syntax used by that command (probably the GNU version, or maybe BSD [openbsd.org] if that's what floats your boat).
Either way, it's probably worth letting tomc know about your script, as the version of find [perl.com]currently on the Perl Power Tools [perl.com] site doesn't implement a lot of the find functionality.
RE: PPT (Score:1)
Though I think it still leaves the ambiguity about finding things named -*, maybe we could use '[' ']' to disambiguate that (of course then we can't find things called '[' or ']'
wildcards (Score:1)
re: wildcards (Score:1)
Sorry, I think you've taken my ramblings a bit too literally. I was talking of nailing down the meaning of /^-/ are commands" rule then that translates to the Perl
-name -red. If I apply a simple "things matching->name()->red(), so how would I get to->name( '-red' ), which is what I really wanted.Perhaps you
...escaping (Score:1)
Nope. (Score:1)
-name '"-red"'
Just to get around the shells quoting. Ewww.
-Dom
Don't use '[' and ']' in command lines (Score:1)
[ .. ]as a shorthand fortest .., so it would be unwise to use those characters.Grouping characters (Score:1)
Odd, not from my the bash on my box, and not in a script either.[0]
This was giving me a little trouble before though, more for consistency with find(1) than anything, so I switched it over to using '(' and ')' as parameters. The hard part is finding a set of grouping characters that aren't significant in any shell, since () themselves are used by bash and zsh.
[0]