The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers > Answers to Frequently Asked Questions
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #9 (permalink)  
Old 07-15-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,122
If you leave it out, then the shell will fail when it tries to exec() it. What happens next depends on which shell you are using as your login shell. Most shells will assume that the script is written in their own language. So if you are using bash as your login shell and try to run a korn shell script that didn't have the #! /usr/bin/ksh, then bash will try to run it as a bash script. bash and ksh are somewhat compatible and this might work. On the other hand, it might fail.

Suppose you use ksh as your login shell and you are running korn shell scripts without that first line. Things seem ok. Then you decide to try bash as your login shell. Suddenly things break.

And things will be especially grim for anyone who uses csh/tcsh as their login shell and runs scripts without that first line. These shells inspect the script to try and guess whether they or the old bourne shell should run it. The test they employ is so bad that it can be beaten by a random number generator. And no one still uses the old bourne shell anyway.

And yes, it is sort of a standard. Most kernels know about it. But I don't believe that is an official posix standard.