Path: utzoo!attcan!uunet!wuarchive!cs.utexas.edu!sun-barr!newstop!texsun!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.unix.questions Subject: Re: How does #!/bin/sh work ? Why does it sometimes not ? Message-ID: <107147@convex.convex.com> Date: 13 Oct 90 02:09:59 GMT References: <7980005@hpopd.HP.COM> Sender: usenet@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 20 In article <7980005@hpopd.HP.COM> ian@hpopd.HP.COM (Ian Watson) writes: >I've seen loads of shell scripts start with >#!/bin/sh >as the first line. > >I understand that the C shell sees this and knows to execute it as a Bourne >shell script. On any system I've seen, it's the kernel who recognizes this (often in sys/kern_exec.c) and launches the proper interpreter. I happen to believe that doing anything else than this is undesirable -- currently either csh or sh may end up being called (on a BSD system) if the program doesn't have either the magic number of compiled a.out or an interpreter line, depending on the first character (# or not) of the file. --tom -- "UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever things." [Doug Gwyn]