[Purdue-pm] Yet more on: Problem with she-bang and PERL5OPT

Rick Westerman westerman at purdue.edu
Thu Nov 20 19:52:50 PST 2014


After reading more on she-bangs in general (and not just she-bangs with Perl and arguments using env) it appears that some systems env accept arguments and others it does not.  And indeed on my Mac system using ‘PERL5OPT=-T perl’ works fine.  However as Doug warned ‘/bin/env’ is not portable — it is not found on my Mac.  So I really need to start using ‘/usr/bin/env’.  In other words the following works fine:

————

#!/usr/bin/env PERL5OPT=-T perl
 
warn 'Taint mode is '.(${^TAINT} ? 'on' : 'off');
  
# End

—————

[Returns: Taint mode is on at ./r.pl line 3. ]

But unfortunately it is not portable to RCAC and RedHat systems. :-(



> On Nov 20, 2014, at 9:04 PM, Mark Senn <mark at ecn.purdue.edu> wrote:
> 
> Rick Westerman <westerman at purdue.edu> wrote on 2014-11-20 at 14:52
> From all I have read the following program should work:
> |  #!/bin/env PERL5OPT=-T perl
> |  
> |  warn 'Taint mode is '.(${^TAINT} ? 'on' : 'off');
> |  
> |  # End
> |  
> |  But when I run it, at least on the RCAC and on the Genomics systems, the
> |  program just hangs.  Take away PERL5OPT and it works.  Put in '-w'
> |  instead of '-T' and it fails in the same manner.  Quoting does not seem
> |  to matter.  Just running from the command line:
> |  
> |  /bin/env PERL5OPT=-T perl program.file
> |  
> |  Works fine.
> |  
> |  I am mystified. Anyone have an idea?
> 
> From
> http://stackoverflow.com/questions/2528959/how-do-i-set-the-taint-mode-in-a-perl-script-with-a-usr-bin-env-perl-sheba
> 
>  You cannot actually specify a variable in a shebang with
>  /usr/bin/env. Doing so will cause env to execve itself in an infinite
>  loop, never even getting to the command requested. I tested this against
>  both Linux and FreeBSD. – Zed
> 
> 
> Rick, I got the sme results with these scripts that you got with yours
>  #!/bin/env /bin/cat
>  hello there
> and
>  #!/bin/env TEMPVAR=hello /bin/cat
>  hello there
> (I wanted to try it with something simpler than perl.)
> 
> -mark



More information about the Purdue-pm mailing list