[comp.unix.questions] #! loader convention

pauld@cs.washington.edu (Paul Barton-Davis) (04/16/91)

I believe that the convention of interpreting #! comments in
"scripts" is built in the loader for BSD. Does anyone know
if any such mechanism exists at the same level in System V ?
I'm looking for more than just some of those brain-damaged
shell conventions like (":" means use /bin/sh), something that
one can guarantee that a call to exec[vlpe] will succeed
even if the file needs an interpeter.

-- 
Paul Barton-Davis			<pauld@cs.washington.edu>
UW Computer Science Lab		``to shatter tradition makes us feel free''

gwyn@smoke.brl.mil (Doug Gwyn) (04/17/91)

In article <1991Apr15.232541.23205@beaver.cs.washington.edu> pauld@cs.washington.edu (Paul Barton-Davis) writes:
>I believe that the convention of interpreting #! comments in
>"scripts" is built in the loader for BSD. Does anyone know
>if any such mechanism exists at the same level in System V ?

It's handled by code in the kernel (part of the exec() system call).
SVR4 is supposed to support this.

guy@auspex.auspex.com (Guy Harris) (04/18/91)

>I believe that the convention of interpreting #! comments in
>"scripts" is built in the loader for BSD.

What do you mean by "the loader"?  It's not in the linker "ld", but it
is in the code in the kernel that handles "exec[vl]" and "exec[vl]e".

>Does anyone know if any such mechanism exists at the same level in System
>V ?

Which release of System V?  The only release from AT&T's UNIX Software
Laboratory, or its predecessor organizations, that has it is System V
Release 4; S5R4 has a full-blown "#!" implementation in the
"exec[vl]"/"exec[vl]e" code (although with, I think, some of the
line-length limitations that BSD has).  *Some* vendors have added "#!"
to OS releases of theirs based on S5 releases from AT&T prior to S5R4;
others haven't. 

ronald@robobar.co.uk (Ronald S H Khoo) (04/18/91)

gwyn@smoke.brl.mil (Doug Gwyn) writes:

> pauld@cs.washington.edu (Paul Barton-Davis) writes:
> >I believe that the convention of interpreting #! comments in
> >"scripts" is built in the loader for BSD. Does anyone know
> >if any such mechanism exists at the same level in System V ?

> It's handled by code in the kernel (part of the exec() system call).
> SVR4 is supposed to support this.

And if you're running System V releases previous to 4, you can
get *some* of the functionality of #! by using a shell that
emulates it for you, e.g. ash (comp.sources.unix archives somewhere).

And, for at least some of the csh's that some System V(<R4) vendors
provide, you can say set shell=/usr/bin/perl to get if you also have a
reasonably recent perl.

But doing this sort of thing does lead to a rather inconsistent system,
so I don't recommend it.
-- 
Ronald Khoo <ronald@robobar.co.uk> +44 81 991 1142 (O) +44 71 229 7741 (H)