On Jun 9, 2007, at 2:18 PM, Michael Jia wrote:

> I did some further research on this topic. My win xp cmd shell seems
> doesn't do wildcard expansion by itself.
>
> C:\working>echo *.txt
> *.txt
>
> There are some posts saying the VC C runtime library is the one  
> actually
> does wildcard expansion. As seen here:
> http://www.lyra.org/pipermail/scite-interest/2002-March/000436.html
>
>
>
> A similar behavior in Java was also reported here,
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6328875
> http://mindprod.com/jgloss/main.html
> http://groups.google.com/group/comp.lang.java.programmer/ 
> browse_thread/thread/a6f188a2d521803e? 
> hl=en&lr=&ie=UTF-8&oe=UTF-8&frame=right&seekm=01be589d%24dc827700% 
> 24baac72d1%40stargate.sgi.net
>
> It seems to me that it is the ruby intepreter was linked to the  
> runtime
> library, namely, startargv.obj, then it gets the expansion for  
> free. :)
>
> Can someone familiar with ruby build please clarify?
>
> -- 
> Posted via http://www.ruby-forum.com/.

rab:Users/rab $ mkdir tmp
rab:Users/rab $ cd tmp
rab:rab/tmp $ touch foo.txt bar.pdf baz.rb
rab:rab/tmp $ echo *.txt
foo.txt
rab:rab/tmp $ echo *.pdf
bar.pdf
rab:rab/tmp $ echo *.java
*.java
rab:rab/tmp $

It also depends what is in the directory at the time of the  
expansion.  If there are no files that match the glob pattern, the  
shell (bash in this case) passes the argument as is (just as if it  
had been '*.java').

rab:rab/tmp $ ruby -e 'puts ARGV.join(" - ")' *.*
bar.pdf - baz.rb - foo.txt
rab:rab/tmp $ ruby -e 'puts ARGV.join(" - ")' *.txt
foo.txt
rab:rab/tmp $ ruby -e 'puts ARGV.join(" - ")' *.pdf
bar.pdf
rab:rab/tmp $ ruby -e 'puts ARGV.join(" - ")' *.java
*.java
rab:rab/tmp $ ruby -e 'puts ARGV.join(" - ")' b*
bar.pdf - baz.rb
rab:rab/tmp $ ruby -e 'puts ARGV.join(" - ")' *f*
bar.pdf - foo.txt
rab:rab/tmp $ ruby -e 'puts ARGV.join(" - ")' '*f*'
*f*

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob / AgileConsultingLLC.com