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

From: Jaap Bril (jaap@ice.nl)
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
GETS THE RIGHT ANSWER (THANKS).

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.

+++++++++++++++++++++++++++++++++++SUN-OS+++++++++++++++++++++++
NAME
     execve - execute a file

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

DESCRIPTION
     .......... 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.Wathne@vest.sdata.no (Birger A. Wathne)
Corvil Howells <corvilh@sa-cgy.valmet.com>
Gene Rackow <rackow@mcs.anl.gov>
Henk.Langeveld@sun.nl (Henk Langeveld - Sun Nederland)
Postmaster <Piete.Brooks@cl.cam.ac.uk>
Richard.Czech@gmd.de (Richard Czech)
adam%bwnmr4@harvard.harvard.edu (Adam Shostack)
ajs6143@eerpf001.ca.boeing.com ( Andy J. Stefancik 206-234-3049 )
bernards@merlin.ecn.nl (Marcel Bernards)
chris@invmms.worldbank.org (Chris Bulle)
don@mars.dgrc.doc.ca (Donald McLachlan)
dtb@otto.bf.rmit.OZ.AU (David Bath)
etnibsd!vsh
heiser@tdwr.ed.ray.com (Bill Heiser)
mharris@jpmorgan.com (Michael Harris)
rwolf@dretor.dciem.dnd.ca
shandelm@jpmorgan.com (Joel Shandelman FIMS Information Systems - 212-648-4480)
stanley@oce.orst.edu (John Stanley)
stephen.dowdy@medtronic.com (Stephen Dowdy)
strombrg@hydra.acs.uci.edu
tkevans@eplrx7.es.duPont.com (Tim Evans)
trinkle@cs.purdue.edu (Daniel Trinkle)
ups!kalli!kevin@fourx.Aus.Sun.COM (Kevin Sheehan {Consulting Poster Child})
vasey@issi.com
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.

ORIGINAL QUESTION

Managers,
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:
#!/bin/csh
.......
csh-script.....
........

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

TIA

Jaap Bril <jaap@ice.nl>
******************************************************************
* INDEPENDENT COMMUNICATION EXPERTS *
* 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