bug-sh-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Possible bug in env Re: Is there a way to make env invoke perl with -


From: JW
Subject: Possible bug in env Re: Is there a way to make env invoke perl with -w ?
Date: Wed, 17 Apr 2002 11:28:59 -0500

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hello,

We have had a long discussion and I have finally come to the conclusion that 
env cannot envoke any interpreter with an argumetn, in spite of what the man 
and info pages say

It works on the command line, as show below, but in a script it fails, treating 
the argument as part of the executable's name, as if it was quoted..

Please, is there any way to get env to envoke perl with the -w and -T options? 

It is a very big problem for us. I can use "use warnings" in place of -w but 
there is no replacement for -T.

See below for portaions of our thread on the topic (address@hidden)

Thank you! 


JW >Hey,
JW >
JW >I just ran into a rather serious (for me) problem where some users were 
calling a specifica installation of perl directly in their scripts:
JW >
JW >#!/usr/local/bin/perl -w
JW >
JW >Because we are doing extensive testing with a number of perl installations, 
I _really_ need to change that to:
JW >
JW >#!/usr/bin/env perl -w
JW >
JW >The problem is, env won't take the -w. If I leave it off it works fine:
JW >
JW >#!/usr/bin/env perl
JW >
JW >but as soon as I put the -w back on I get:
JW >/usr/bin/env: perl -w: No such file or directory
JW >
JW >Apparently env thinks "-w" is a binary to execute in addition to perl.
JW >
JW >From the man page I think that env _can_ take args:
JW >
JW >       env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
JW >
JW >But how?

JW >TA >On Tue, 16 Apr 2002, David Talkington wrote:
JW >TA >
JW >TA >> >#!/usr/bin/env perl -w
JW >TA >
JW >TA >This will work:
JW >TA >
JW >TA >        #! /usr/bin/env - perl -w
JW >TA >
JW >TA >You were missing the dash to tell env that everything after should be
JW >TA >passed on to perl, instead of being a switch for env itself. :)
JW >
JW >But I tried that, having got the idea from the man page. This is what I 
used:
JW >
JW >#!/usr/bin/env - perl -w (or #! /usr/bin/env - perl -w )
JW >
JW >And this is what I get:
JW >
JW >devcp cpbackend2/engine> ./bg_customersubaccountspiderkeyword2 
--customersubaccountid=14 --seid=1 --remote=self
JW >/usr/bin/env: invalid option --
JW >Try `/usr/bin/env --help' for more information.
JW >devcp cpbackend2/engine>
JW >
JW >
JW >Maybe it's freaking out over the shell arguments, I dunno.
JW >
JW >Any more ideas?
JW >

JW >JS >On Tue, 16 Apr 2002, JW wrote:
JW >JS >
JW >JS >
JW >JS >Both the man and info (urggh) page say:
JW >JS >
JW >JS >SYNOPSIS
JW >JS >       env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
JW >JS >
JW >JS >DESCRIPTION
JW >JS >       Set each NAME to VALUE in the environment and run COMMAND.
JW >JS >
JW >JS >
JW >JS >So... will it really work like this?
JW >JS >
JW >JS >!#/usr/bin/env - perl -w
JW >JS >
JW >JS >I thought you'd have to give it something like:
JW >JS >
JW >JS >env - PERL=/usr/bin/perl -w
JW >JS >
JW >JS >etc?
JW >JS >
JW >JS >Probably talking through my hat as usual... ;-)
JW >
JW >But that completely defeats the purpose of this exercise, which is to have 
env find perl (yes, perl is moving around ;-).
JW >
JW >Unless it could be:
JW >
JW >    env - PERL=`which perl` -w
JW >
JW >But that's too wierd, I could hardly belive that.
TA >On Wed, 17 Apr 2002, Juha Saarinen wrote:
TA >
TA >> pts/0 address@hidden:~$ env -i PATH=/usr/bin/ perl -w hello.pl
TA >> Hello, World!
TA >
TA >It works from the command line, but not on a shebang line. 


TA >Apparently, this will work from the command line:
TA >
TA >    env - perl -we 'print "Foo\n"'  
TA >
TA >but not from a shell script. Interesting. Not sure what to tell you.
TA >

- -- 

- ----------------------------------------------------
Jonathan Wilson
System Administrator
Clickpatrol.com
Cedar Creek Software     http://www.cedarcreeksoftware.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8vaLMQ5u80xXOLBcRAmSIAJ9cMyHgtfWicnHjCoT1NHgRjPG7rACfTWcd
0TU8Z3Lr+z1coj5uuawDIHQ=
=9EaG
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]