[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

env question

Brian Schröder

10/5/2004 10:04:00 AM

Hello Group,

This is maybe not exactly a ruby question, but maybe you have also
thought about this.

I like to use
#!/usr/bin/env ruby
as a shebang line. On the other hand, I also like calling ruby with -w

I can't get env to call ruby with arguments. Things that are not working:
#!/usr/bin/env ruby -w
#!/usr/bin/env 'ruby -w'

Could anyone help me on this one?

regards,


Brian
--
Brian Schröder
http://ruby.brian-sch...


15 Answers

Florian Frank

10/5/2004 10:25:00 AM

0

On 05.10.2004, at 12:04, Brian Schröder wrote:
> Could anyone help me on this one?

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

Florian Frank




Yukihiro Matsumoto

10/5/2004 1:02:00 PM

0

Hi,

In message "Re: env question"
on Tue, 5 Oct 2004 19:25:16 +0900, Florian Frank <flori@nixe.ping.de> writes:

|On 05.10.2004, at 12:04, Brian Schröder wrote:
|> Could anyone help me on this one?
|
|#!/usr/bin/env ruby
|$VERBOSE = true

If you don't need compile-time check.

matz.



Robert Klemme

10/5/2004 1:50:00 PM

0


"Yukihiro Matsumoto" <matz@ruby-lang.org> schrieb im Newsbeitrag
news:1096981307.926461.11274.nullmailer@x31.priv.netlab.jp...
> Hi,
>
> In message "Re: env question"
> on Tue, 5 Oct 2004 19:25:16 +0900, Florian Frank
<flori@nixe.ping.de> writes:
>
> |On 05.10.2004, at 12:04, Brian Schröder wrote:
> |> Could anyone help me on this one?
> |
> |#!/usr/bin/env ruby
> |$VERBOSE = true
>
> If you don't need compile-time check.

Personally I don't understand why pople use the "#!/usr/bin/env ruby"
idiom anyway. AFAIK using the real path to the ruby interpreter is a)
more efficient and b) more secure. So why use env? Did I miss something?

Kind regards

robert

Ara.T.Howard

10/5/2004 2:04:00 PM

0

Robert Klemme

10/5/2004 2:28:00 PM

0


<Ara.T.Howard@noaa.gov> schrieb im Newsbeitrag
news:Pine.LNX.4.60.0410050756510.7297@harp.ngdc.noaa.gov...
> On Tue, 5 Oct 2004, Robert Klemme wrote:
>
> > Personally I don't understand why pople use the "#!/usr/bin/env ruby"
idiom
> > anyway. AFAIK using the real path to the ruby interpreter is a) more
> > efficient and b) more secure. So why use env? Did I miss something?
>
> many of my scripts are run from 30-40 machines. some of the machines
mount a
> central nfs server on which i've installed ruby and all required
packages for
> my software. however, as an optimization and to improve nfs failure
tolerance
> many of our machine cache a lot of software (including ruby) and data
files
> further up the path than the nfs ruby. finally, a third class of
machines has
> the system ruby only (1.6.8). if i write a script and use
>
> #!/usr/bin/env ruby
>
> the system finds the 'right' ruby at run time. without this i'd have to
> maintain many copies of my scripts. this problem extends to the
situation
> where i give you a ruby script and don't know where your ruby is, and to
> upgrading ruby (i have 1.8.1 before 1.8.2 in our group path because i'm
> migrating to 1.8.2, but reverse this for testing). env helps with all
of this
> and, yes, it's probably less secure - but so is anything that involves
getting
> alot of work done quickly ;-)

Sure enough. But what's the advantage over

#!ruby

Are there shells that don't allow this? Does env search not only $PATH
but elsewhere?

Kind regards

robert

Ara.T.Howard

10/5/2004 2:51:00 PM

0

Robert Klemme

10/5/2004 3:49:00 PM

0


<Ara.T.Howard@noaa.gov> schrieb im Newsbeitrag
news:Pine.LNX.4.60.0410050843500.7297@harp.ngdc.noaa.gov...
> On Tue, 5 Oct 2004, Robert Klemme wrote:
>
> > Sure enough. But what's the advantage over
> >
> > #!ruby
> >
> > Are there shells that don't allow this?
>
>
> jib:~ > for shell in tcsh csh sh bash ksh;do echo $shell; $shell -c
../a.rb;done
> tcsh
> ./a.rb: Command not found.
> csh
> ./a.rb: Command not found.
> sh
> sh: ./a.rb: ruby: bad interpreter: No such file or directory
> bash
> bash: ./a.rb: ruby: bad interpreter: No such file or directory
> ksh
> ksh: ./a.rb: No such file or directory
>
> does that work for you - if so what os/shell?

17:46:28 [ruby]: for sh in `cat /etc/shells` ; do echo $sh; $sh -c ./a.rb;
done
/bin/sh
yes!
/bin/bash
yes!
/bin/ksh
yes!
/bin/pdksh
yes!
/bin/tcsh
yes!
/bin/zsh
yes!
/usr/bin/sh
yes!
/usr/bin/bash
yes!
/usr/bin/ksh
yes!
/usr/bin/pdksh
yes!
/usr/bin/tcsh
yes!
/usr/bin/zsh
yes!
17:46:48 [ruby]: cat ./a.rb
#!ruby
puts "yes!"
17:46:56 [ruby]: uname -a
CYGWIN_NT-5.0 bond 1.5.10(0.116/4/2) 2004-05-25 22:07 i686 unknown unknown
Cygwin

I'll check on my debian when I'm at home.

> > Does env search not only $PATH but elsewhere?
>
> AFAIK it searches only in $PATH.

Ok, that's what I thought.

Kind regards

robert

Michael Campbell

10/5/2004 5:55:00 PM

0

On Wed, 6 Oct 2004 00:49:55 +0900, Robert Klemme <bob.news@gmx.net> wrote:

> 17:46:28 [ruby]: for sh in `cat /etc/shells` ; do echo $sh; $sh -c ./a.rb;
> done
> /bin/sh
> yes!

.


Robert, you're EXPLICITLY running each shell; that's different from
what Ara did; he was having the shell parse the #! line. If you go
with "$sh -c rubyscript", you don't need the #! at all, which makes
the question moot, no?


Robert Klemme

10/6/2004 8:22:00 AM

0


"Michael Campbell" <michael.campbell@gmail.com> schrieb im Newsbeitrag
news:811f2f1c041005105466eefc5b@mail.gmail.com...
> On Wed, 6 Oct 2004 00:49:55 +0900, Robert Klemme <bob.news@gmx.net>
wrote:
>
> > 17:46:28 [ruby]: for sh in `cat /etc/shells` ; do echo $sh; $sh -c
../a.rb;
> > done
> > /bin/sh
> > yes!
>
> .
>
>
> Robert, you're EXPLICITLY running each shell; that's different from
> what Ara did; he was having the shell parse the #! line. If you go
> with "$sh -c rubyscript", you don't need the #! at all, which makes
> the question moot, no?

Each shell is run individually but it evaluates the first line of the
script; the test is quite the same as Ara's. Please read the code again
carefully.

robert

Heather L.

4/10/2010 12:19:00 AM

0

Rick wrote:
> Reverend Dave wrote:
>> duke<duckgumbo32@cox.net> wrote in
>> news:n8fsr55rgl2mp77fk7cfh4s1j8hetnukdr@4ax.com:
>>
>>> On Mon, 05 Apr 2010 18:25:06 -0600, Virgil<Virgil@home.esc> wrote:
>>>
>>>>> Atheists have beliefs all of which are erroneous.
>>>
>>>> If that were so, it would be a refutation of the scientific
>>>> theories of quantum theory, relativity, evolution and all of the
>>>> many other scientific theories that the brightest scientists,
>>>> almost all of whom are atheists, believe in.
>>>
>>> God created every law of science throughout the universe, known and
>>> unknown.
>>
>> I can't seem to find the Bible quote that proves this. Do you have
>> it?
>
> You apparently missed the first sentence: "In the beginning was the
> word..." WORD to many stands for all the LAWS of God & science.

Really? Most scientific laws I know are best stated in algebraic symbols. So
what has a big WORD got to do with anything...?

What's more, in a literal translation, the Bible's 'first sentence' is:
1In the beginning of God's preparing the heavens and the earth

Nothing about WORD or LAWS there, dipshit.

What you're talking about, being an ignorant, credulous cretin, is merely
the start of the Book of John, which wasn't even written by John:
http://www.biblegateway.com/passage/?search=John+1&v...

Anything else I can help you with, dipshit? Do you need help finding your
arse with both hands...?

HL.