SUMMARY: How to tell the shells which shell to use?

From: Jaap Bril (
Date: Tue Apr 27 1993 - 13:52:25 CDT

SUMMARY: How to tell the shells which shell to use?

'Well, where is the problem?' would have been my answer to this question too
as '#!' had never before given any reason to complain.

But, as with all 'well known features' one tends to forget which part
of a system provides them and when it doesn't work (it does not on SCO)
one looks in the wrong direction, asks the wrong question and

The interpretation of the magic token '#!' is not supposed to be
a feature of the shell but an OS-feature. More specificaly the
'execve()' system-call in 'BSDoid' kernels provide this facility.

     execve - execute a file

     int execve(path, argv, envp)
     char *path, **argv, **envp;

     .......... either an executable object file, or a file of
     data for an interpreter............

     An interpreter file begins with a line of the form `#!
     interpreter [arg]', which is at most thirty-two characters.
     When an interpreter file is execve'd, the system execve's
     the specified interpreter................

CAVEAT (from different respondents)

        Don't expect an easy life if you want too source the interpreter files.
        Some say it can't be done.

        Be absulutely sure .cshrc / .login /etc. don't screw up the environment
        or use f.i. '#!/bin/csh -f' it gets faster too.

        ONLY interpreters that use '#' for the comment character can be used
        this way.

SUGGESTIONS(from different respondents)

        use PERL
        don't use CSH for interpreter files
        use anything but CSH

Well, at least I know why it doesn't work on the 'new' machine...

THANKS to all respondents:

Barry Margolin <barmar@Think.COM> (Birger A. Wathne)
Corvil Howells <>
Gene Rackow <> (Henk Langeveld - Sun Nederland)
Postmaster <> (Richard Czech) (Adam Shostack) ( Andy J. Stefancik 206-234-3049 ) (Marcel Bernards) (Chris Bulle) (Donald McLachlan) (David Bath)
etnibsd!vsh (Bill Heiser) (Michael Harris) (Joel Shandelman FIMS Information Systems - 212-648-4480) (John Stanley) (Stephen Dowdy) (Tim Evans) (Daniel Trinkle)
ups!kalli!kevin@fourx.Aus.Sun.COM (Kevin Sheehan {Consulting Poster Child})
vlsiphx!perlotto (Richard E. Perlotto II)
zeke@mpl.UCSD.EDU (Rob Scott)

PS. I never expected that so many people had such strong opinions
        on the use of shells.


We recently acquired ;-) a group of ksh and sh users. As we want them to
use some of our csh-scripts, who want to write the same script in three shells,
we need to know how to tell ksh and sh that the script is a csh-script.

In our scripts we use:

Does something like this exist that works for csh as well as ksh and sh?


Jaap Bril <>
* Korenpad 1 *
*Tel: +31 80 540140 6534 AS Nijmegen*
*Fax: +31 80 566152 The Netherlands *

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:07:47 CDT