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

Re: Stupid shebang tricks



On Wed, May 11, 2005 at 11:04:06PM +1000, Ben Finney wrote:
> On 11-May-2005, martin f krafft wrote:
> > also sprach Ben Finney <ben@benfinney.id.au> [2005.05.11.0307 +0200]:
> > > To what extent should that be used? Is it reasonable to do it for
> > > *any* shebang line? '#!/usr/bin/env make'? '#!/usr/bin/env bash'?
> 
> > Debian standardises executable locations, so there is no need for
> > lookup.
> 
> The context of the '#!/usr/bin/env python' trick extends beyond Debian
> though; the whole point is that a lookup will work in environments where
> the location of the executable *isn't* the standard one.
> 
> If we could safely assume our scripts would only ever be run on Debian
> systems, we could dispense with a great many portability tricks.

My solution, using perl scripts as an example, is to write

  #!@PERL@ -w

and use autoconf to generate the script for me, using

  AC_PATH_PROG([PERL], [perl])

and naming the script myscript.in, which is processed by configure to
create myscript, where the top line now reads

  #!/usr/bin/perl -w

This also allows any other configure substitutions to be made (version
information, paths and file locations, configuration information etc.)

This applies equally to python and any other scripting languages.


Regards,
Roger

-- 
Roger Leigh

                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.



Reply to: