# File template as command line param?

**URL:** <https://www.ruby-forum.com/t/file-template-as-command-line-param/116789>\
**Category:** Ruby\
**Created:** [October 9, 2007, 8:00pm UTC](https://www.ruby-forum.com/t/file-template-as-command-line-param/116789 "2007-10-09T20:00:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bazsl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ad7895/32.png) [@Bazsl](https://www.ruby-forum.com/u/Bazsl)\
**Post date:** [October 9, 2007, 8:00pm UTC](https://www.ruby-forum.com/t/file-template-as-command-line-param/116789/1 "2007-10-09T20:00:35Z")

</div>

If I pass \*.rb as a command line parameter to a Ruby script ARGV  
contains the names of the files matching the template, not \*.rb. Is  
there a way to pass a file template as a command line parameter and have  
it passed literally instead of being interpreted and expanded?

---

<div class="post-metadata">

**Author:** ![Bazsl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ad7895/32.png) [@Bazsl](https://www.ruby-forum.com/u/Bazsl)\
**Post date:** [October 9, 2007, 8:12pm UTC](https://www.ruby-forum.com/t/file-template-as-command-line-param/116789/2 "2007-10-09T20:12:54Z")

</div>

> it passed literally instead of being interpreted and expanded?

That has nothing to do with Ruby, but with shell expansion. Single  
quotes  
prevent shell expansion in all shells, as far as I know:

$ ruby -e ‘puts ARGV’ _.rb  
test.rb  
$ ruby -e ‘puts ARGV’ '_.rb’  
\*.rb

HTH,

Felix

---

<div class="post-metadata">

**Author:** ![Bazsl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ad7895/32.png) [@Bazsl](https://www.ruby-forum.com/u/Bazsl)\
**Post date:** [October 10, 2007, 12:56am UTC](https://www.ruby-forum.com/t/file-template-as-command-line-param/116789/3 "2007-10-10T00:56:05Z")

</div>

On Oct 9, 1:59 pm, Bazsl [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> If I pass \*.rb as a command line parameter to a Ruby script ARGV  
> contains the names of the files matching the template, not \*.rb. Is  
> there a way to pass a file template as a command line parameter and have  
> it passed literally instead of being interpreted and expanded?

brian@imagine:~/temp$ cat \> temp.rb  
require ‘pp’  
pp ARGV  
brian@imagine:~/temp$ ruby temp.rb _.rb  
[“back.rb”, “junk.rb”, “qsort.rb”, “temp.rb”]  
brian@imagine:~/temp$ ruby temp.rb "_.rb"  
[“\*.rb”]
