[comp.unix.questions] csh scripts on sys V question

megabyte@chinet.UUCP (Dr. Megabyte) (11/18/86)

I now have a copy of the 'C' shell running on my SYS V R2 at&t 3b2/400. It
works perfectly as my command interpetor and will run all 'C' shell scripts
_IF_ I type "csh script".  Now, is there anyway for me to set up my 3b2 so that
I can just type "script" and have the proper shell chosen, either Bourne or
'C'? I know that Unix ala Berkely has this built in to the kernal, but is there
anyway to "hack" or "fake" sys V into doing this also?  Suggestions for changes
to csh are also encouraged if that will help matters any.

The opinions expressed herein are my own and do not reflect those of 
the Internal Revenue Service or any other agency of the United States
Government. (A US Gov't disclaimer designed to protect the taxpayers 
from their fellow taxpayers)
-- 
UUCP:	(1) seismo!why_not!scsnet!sunder		Mark E. Sunderlin
	(2) ihnp4!chinet!megabyte			aka Dr. Megabyte
CIS:	74026,3235					(202) 634-2529
Mail:	IRS  PM:PFR:D:NO  1111 Constitution Ave. NW  Washington,DC 20224  

mcvoy@rsch.WISC.EDU (Lawrence W. McVoy) (11/19/86)

In article <787@chinet.UUCP> megabyte@chinet.UUCP (Dr. Megabyte) writes:
>_IF_ I type "csh script".  Now, is there anyway for me to set up my 3b2 so that
>I can just type "script" and have the proper shell chosen, either Bourne or
>'C'? 

As I understand it the sh is started up to handle shell scripts, right?
In Bezerkeley Unix I think the kernel figures out what program to exec.
I don't see why the sh couldn't do this.  For instance, change the sh to
look at the first line and exec it if the line is of the form

'#' '!' <program name>

and program name != '/bin/sh' or 'sh'

Anybody have any problems with this?
-- 
Larry McVoy 	        mcvoy@rsch.wisc.edu, 
      		        {seismo, topaz, harvard, ihnp4, etc}!uwvax!mcvoy

"They're coming soon!  Quad-stated guru-gates!"

ggs@ulysses.UUCP (Griff Smith) (11/20/86)

> In article <787@chinet.UUCP> megabyte@chinet.UUCP (Dr. Megabyte) writes:
> >_IF_ I type "csh script".  Now, is there anyway for me to set up my 3b2 so that
> >I can just type "script" and have the proper shell chosen, either Bourne or
> >'C'? 
> 
> As I understand it the sh is started up to handle shell scripts, right?
> In Bezerkeley Unix I think the kernel figures out what program to exec.
> I don't see why the sh couldn't do this.  For instance, change the sh to
> look at the first line and exec it if the line is of the form
> 
> '#' '!' <program name>
> 
> and program name != '/bin/sh' or 'sh'
> 
> Anybody have any problems with this?
> -- 
> Larry McVoy 	        mcvoy@rsch.wisc.edu, 

It could, but the shell isn't the only path for program execution.  The
scheme in BSD (and V8, I think, (unless they took that one out too))
allows one to exec a shell script from within an arbitrary process.

There is also a bit of a problem with assuming that the shell's name is
/bin/sh.  We use two names: /bin/sh and /bin/ksh.  /bin/sh is the
blessed version of the Korn shell, /bin/ksh is the latest version from
Dave Korn.  Sometimes the two are linked, sometimes they're not.  The
shell may not know its name; the safest assumption is for it to use a
forked copy of itself only when there is no name on the initial comment
line.
-- 

Griff Smith	AT&T (Bell Laboratories), Murray Hill
Phone:		(201) 582-7736
UUCP:		{allegra|ihnp4}!ulysses!ggs
Internet:	ggs@ulysses.uucp