On 9/7/07, Beni Cherniavsky <[EMAIL PROTECTED]> wrote:
> "#!" 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).
>

<nit size='microscopic'>

Actually, the true, canonically correct way is to use

#! /usr/bin/env perl -w
(Notice that the third character is a space)

'#! /' is a 32-bit magic cookie that is used to identify executable
scripts by the kernel. But since everyone skips using the space, all
modern kernels also allow the 24-bit magic cookie '#!/'.
</nit>

But that is as long as the Linux kenel goes. There are lots of other
more or less widely used shebang-cousins that some shells implement:

* Having a lone colon (':') on the first line, meaning the same thing
as '#! /bin/sh'
* #!perl, as per Tassilos example
* Using th .sh suffix to denote shellscripts.

These are all ugly warts, they are non-standard and offer no new
functionality what so ever, and should never be used. I wish I could
say that fish implements none of them, but I am weak and easily
influenced, and went along with including the first one in fish. I do
not want to implement the other two as well.

Axel

> 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
> > Fish-users@lists.sourceforge.net
> > 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
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to