Bug in #! processing

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Fri Oct 1 05:45:38 PDT 2004


On Thu, 2004-09-30 at 09:16, Sławek Żak wrote:
> "David G. Lawrence" <dg at dglawrence.com> writes:
> >    The #! is required to be in the first two bytes of the file, so there
> > can't be any spaces before it.
> 
>     Oh. Thus in following script:
> 
> thirst<zaks>(1950)% cat tst.sh
>     #!/bin/no-such-file
> ps -lp $$

exec*() fails in that case, and shells assume it's a sh script.  csh
(used to?) assume a csh script if the first character is #, or you can
use "alias shell" to tell it which shell to assume.  This is how scripts
worked before #!.

-- 
brandon s. allbery    [linux,solaris,freebsd,perl]     allbery at kf8nh.com
system administrator      [WAY too many hats]        allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon univ.         KF8NH



More information about the freebsd-current mailing list