[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Shell glob functionality missing?

Wayne Magor

1/8/2008 9:54:00 PM

If you call a Ruby script with a parameter such as:

c:\my source\*\*.c

Ruby will give an array in ARGV that contains all the c files in all
the directories. It will also turn the backslashes into forward
slashes. There doesn't seem to be a method in Ruby that does this
same thing. The Dir.glob and Dir.entries methods don't work this way.

Am I missing something, or is there no easy built-in method for doing
this in Ruby? Doesn't it seem like it should be there? I would think
this would be a common thing for scripting.
1 Answer

Drew Olson

1/8/2008 10:46:00 PM

0

Wayne Magor wrote:
> If you call a Ruby script with a parameter such as:
>
> c:\my source\*\*.c
>
> Ruby will give an array in ARGV that contains all the c files in all
> the directories. It will also turn the backslashes into forward
> slashes. There doesn't seem to be a method in Ruby that does this
> same thing. The Dir.glob and Dir.entries methods don't work this way.
>
> Am I missing something, or is there no easy built-in method for doing
> this in Ruby? Doesn't it seem like it should be there? I would think
> this would be a common thing for scripting.

Dir.glob("c:\mysource\**\*.c")

Use two *, that allows recursive directory searching with glob.

- Drew
--
Posted via http://www.ruby-....