How does Unix kernel find /bin/sh?

Doug Gwyn gwyn at smoke.BRL.MIL
Mon Aug 28 18:26:54 AEST 1989


In article <5 at minya.UUCP> jc at minya.UUCP (John Chambers) writes:
>the "#!" notation.  You'd think by now that everyone would realize
>what a Good Idea this is, and it'd have been installed everywhere.

I think it's slated for SVR4.0.  However, not everyone agrees that
it's a Good Thing.  It causes problems when porting scripts across
systems, because the various interpreter utilities may not have
identical pathnames across systems.  Also, some of us have relied
on System V NOT understanding the #! convention, and our scripts
will break when SVR4.0 arrives.

>The problem is simple:  when I exec a script directly, the kernel
>doesn't run /bin/sh, it runs /bin/bsh!

No, it's run under whatever shell you're already running.  The
shell forks a subshell to handle the script, after the direct
exec() system call fails.

>I've yet to see any mention of the "#!" notation in any document anywhere;

It's documented in the 4.3BSD PRM under EXECVE(2).



More information about the Comp.unix.wizards mailing list