Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.unix.questions Subject: Re: How does #!/bin/sh work ? Why does it sometimes not ? Message-ID: <14139@smoke.BRL.MIL> Date: 12 Oct 90 15:36:54 GMT References: <7980005@hpopd.HP.COM> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 17 In article <7980005@hpopd.HP.COM> ian@hpopd.HP.COM (Ian Watson) writes: >#!/bin/sh On systems that support this, the kernel takes care of it as indicated under EXEC(2) in the reference manual. >I understand that the C shell sees this ... Normal shells first try to exec() the file, and if that fails due to unknown executable image format then MIGHT peek at the FIRST character to determine whether or not a Bourne shell or C-shell should be used to interpret the file. The C-shell often is set up to decide that an initial '#' character indicates the file is a C-shell script, but of course that is not a reliable test. Other shells simply always use a Bourne shell, which is what I recommend. It is possible that somebody has hacked their shells to try to apply full #!-style decoding in lieu of having support for it in exec(), but that would be pretty awful.