Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!mp.cs.niu.edu!rickert From: rickert@mp.cs.niu.edu (Neil Rickert) Newsgroups: comp.unix.shell Subject: Re: the #! notation Message-ID: <1991Jan21.174803.6661@mp.cs.niu.edu> Date: 21 Jan 91 17:48:03 GMT References: <1991Jan16.162705.580@cid.aes.doe.CA> Distribution: na Organization: Northern Illinois University Lines: 26 In article <1991Jan16.162705.580@cid.aes.doe.CA> afsipmh@cidsv01.cid.aes.doe.CA () writes: > > Could someone clear up something for me? > - If i put #! /bin/csh on the first line of a script > the c shell will run it. If I put #! /bin/sh the > Bourne shell will etc. > This is all well and good BUT does it assume that I am > starting out in the c shell i.e. is the #! being interpreted > by the c shell. What if my default were Bourne or ksh? If your system supports '#!', these symbols are interpreted by the kernel, not by the shell. A process 'exec's a new command. The kernel checks the 'magic number' at the beginning of the file to ensure that this is an executable binary for this processor. If it discovers that the 'magic number' is '#!' it reads the name of the interpreter program and loads that instead of the original file, but with the original file name as an argument. In other words '#!', if supported, will work equally from the Bourne shell, or any other shell, or even from a C program you write yourself. -- =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= Neil W. Rickert, Computer Science Northern Illinois Univ. DeKalb, IL 60115 +1-815-753-6940