Passing arguments to 'env ruby' on OS X

J

Jim Freeze

When using env on the shebang line,
how to I pass arguments to Ruby under OS X?

Doing the following gives me an error on OS X, but
works on FreeBSD and Sun:

% cat w.rb
#! /usr/bin/env ruby -w

% puts "hi"

./w.rb
env: ruby -w: No such file or directory
 
N

nobu.nokada

Hi,

At Wed, 16 Jul 2003 20:56:09 +0900,
Jim said:
When using env on the shebang line,
how to I pass arguments to Ruby under OS X?

#! /usr/bin/env ruby
$VERBOSE = true

Or you can use /bin/sh instead of /usr/bin/env.

#!/bin/sh
# -*- ruby -*-
exec ruby -wx "$0" "$@"
#!ruby
 
P

Paul Brannan

#!/bin/sh
# -*- ruby -*-
exec ruby -wx "$0" "$@"
#!ruby

Will this work if I run "ruby myscript.rb" on a Windows box?

If not, is it possible to make that case work?

Paul
 
N

nobu.nokada

Hi,

At Wed, 16 Jul 2003 22:47:50 +0900,
Paul said:
Will this work if I run "ruby myscript.rb" on a Windows box?

Do you mean whether it works as a script directly?

#! /bin/sh
# -*- ruby -*- # just for editors
[ ] || 'eval' 'exec ruby -wx "$0" "$@"'
#!ruby
puts "hi"
If not, is it possible to make that case work?

If you want a way to make a batch file from a script, look at
"ruby_bin_dosish" portion in instruby.rb.

I don't guess it is possible to merge ruby/shell/batch.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top