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

Stupid shebang tricks



On 11-May-2005, Goswin von Brederlow wrote:
> Ben Finney <ben@benfinney.id.au> writes:
> > The good thing about the (standard?) shebang convention -- using a
> > first line of '#!/path/to/shell' in the executable file -- is that
> > you can have executable scripts shared even between different
> > Unices and architectures. If the named shell exists, it should be
> > able to execute the script. (If not, that's a bug in the shell or
> > the script.)
> 
> Something you sometimes see is
> 
> #!/usr/bin/env python
> 
> Env then looks for python in the path and executes the script. Since
> env is small and a system thing it is available everywhere while
> python can be anywhere. That way you can have your python in
> /usr/bin/arch-os/ for each arch/os combo and the script still works.

Yes, I've always been impressed with that trick (in direct proportion
to the hatred I had of '#!/usr/bin/perl' and '#!/usr/local/bin/perl'
wars).

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'?
Are there any downsides?

-- 
 \       "bash awk grep perl sed, df du, du-du du-du, vi troff su fsck |
  `\                  rm * halt LART LART LART!"  -- The Swedish BOFH, |
_o__)                                            alt.sysadmin.recovery |
Ben Finney <ben@benfinney.id.au>

Attachment: signature.asc
Description: Digital signature


Reply to: