Re: What is this doing: eval 'exec /usr/bin/perl -T -w -S $0 ${1+"$@"}' if 0;

2004-08-09 Thread JupiterHost.Net
Jose Alves de Castro wrote:
On Sun, 2004-08-08 at 04:06, JupiterHost.Net wrote:
I found this code in a script right after the she-bang line:
eval 'exec /usr/bin/perl -T -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
What is it doing?

Hi.
From `perldoc perlrun`, under -S :
Hello Jose,
Right on, you'd think I'd check perldoc first, every now and then I get 
dumb ;p

Thanks!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: What is this doing: eval 'exec /usr/bin/perl -T -w -S $0 ${1+"$@"}' if 0;

2004-08-09 Thread Jose Alves de Castro
On Sun, 2004-08-08 at 04:06, JupiterHost.Net wrote:
> I found this code in a script right after the she-bang line:
> 
> eval 'exec /usr/bin/perl -T -w -S $0 ${1+"$@"}'
>  if 0; # not running under some shell
> 
> What is it doing?

Hi.

From `perldoc perlrun`, under -S :

Typically this is used to emulate #! startup on platforms that
don't support #!.  This example works on many platforms that have
a shell compatible with Bourne shell:

#!/usr/bin/perl
eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
if $running_under_some_shell;

[ ... etc ... ]

It goes on, so you have a more detailed explanation there...

The line you have is similar enough to that one.

> Its like its executing itself again, but why?
> 
> What the heck is: ${1+"$@"} ??
> 
> Wouldn't the eval never get done because of the if 0; ??

Right. Probably your system supports #!, right? :-)

> So why eval a piece of code that willnever be eval'ed ?

I guess the line is still there for some reason... I can think of
several possibilities :-|

> 
> Thanks!
> 
> Lee.M - JupiterHost.Net
-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


signature.asc
Description: This is a digitally signed message part


What is this doing: eval 'exec /usr/bin/perl -T -w -S $0 ${1+"$@"}' if 0;

2004-08-07 Thread JupiterHost.Net
I found this code in a script right after the she-bang line:
eval 'exec /usr/bin/perl -T -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
What is it doing?
Its like its executing itself again, but why?
What the heck is: ${1+"$@"} ??
Wouldn't the eval never get done because of the if 0; ??
So why eval a piece of code that willnever be eval'ed ?
Thanks!
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]