"#!" is supported by the kernel.  Support varies a between different
unix kernels and unfortunately is quite crippled in most cases:
* all(?) kernels require a full path!  "#!/usr/bin/env perl" is the
classic solution.
* many only accept one option argument (meaning you can't do
"#!/usr/bin/env perl -w").
* many truncate the line at some arbitrary short length
* many non-unix systems have ports of bash and perl but don't support
"#!" at all
* POSIX doesn't even define "#!"
See http://www.in-ulm.de/~mascheck/various/shebang/ for the gory details.

This "eval 'exec ..." thing is one of several hacks carefully designed
to be valid syntax under both sh (any bourne-compatible shell) and
perl, making sure that you scripts eventually runs under perl.
perl has several features to help with such hacks (-x, internal
parsing of "#!" options).  See
http://www.perl.com/doc/manual/html/pod/perlrun.html for details (and
a different hack of similar effect).

On 9/6/07, Tassilo Horn <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a perl script which starts with these lines:
>
> --8<---------------cut here---------------start------------->8---
> eval 'exec perl -x $0 ${1+"$@"}' # -*-perl-*-
>   if 0;
> #!perl -w
> #
> # Grab daily cartoons from their web sites.
> # Diego Zamboni, Oct 28, 1998.
> #
>
> use FindBin;
> use Getopt::Long;
> --8<---------------cut here---------------end--------------->8---
>
> It's executable and in PATH, but when I want to execute it I get:
>
> ,----
> | [EMAIL PROTECTED] ~> grabcartoons.pl
> | fish: Failed to execute process "/usr/bin/grabcartoons.pl"
> | execve: No such file or directory
> | fish: Backtrace:
> | fish [0x80734a2]
> | fish: Job 1, "grabcartoons.pl" terminated by signal SIGINT (Quit request 
> from job control (^C))
> `----
>
> As a workaround I changed the script to use a normal shebang line, but
> bash executes the script as-is.  Is that start of the script specific to
> bash?
>
> Ah, and if I use the shebang "#!perl -w" I get the same error.  Is there
> a reason an absolute path is required?  perl is in PATH, so I would
> expect that shebang to work fine.
>
> Bye,
> Tassilo
> --
> Chuck Norris  originally wrote the first dictionary.  The definition for
> each word is as follows - A swift roundhouse kick to the face.
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> _______________________________________________
> Fish-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/fish-users
>


-- 
Beni Cherniavsky <[EMAIL PROTECTED]> (I read email only on weekends)

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to