Ben Finney <[EMAIL PROTECTED]> writes: > On 11-May-2005, Goswin von Brederlow wrote: >> Ben Finney <[EMAIL PROTECTED]> 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).
Perl is certainly another candidate for it if you have to work with multiple OS and archs. > 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? I wouldn't use it for bash as I wouldn't be using bash but /bin/sh. But then there are some OSes where /bin/sh is to screwed up and you want bash instead none the less. At university I use #!/bin/sh in combination with testing if the shell actualy is bash and reexecuting oneself with bash if not. That seem to work best. MfG Goswin -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]