File template as command line param?

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?

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

On Oct 9, 1:59 pm, Bazsl [email protected] 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?

[email protected]:~/temp$ cat > temp.rb
require ‘pp’
pp ARGV
[email protected]:~/temp$ ruby temp.rb .rb
[“back.rb”, “junk.rb”, “qsort.rb”, “temp.rb”]
[email protected]:~/temp$ ruby temp.rb "
.rb"
["*.rb"]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs