Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!beartrk!ceilidh!dnichols From: dnichols@ceilidh.beartrack.com (DoN Nichols) Newsgroups: comp.sys.att Subject: Re: Does #!/bin/sh work w/tcsh? (was: Re: Shells for SYSV machines) Message-ID: <1991Jun18.235218.4015@ceilidh.beartrack.com> Date: 18 Jun 91 23:52:18 GMT References: <1991Jun17.202345.10281@agate.berkeley.edu> <1991Jun17.210456.13495@agate.berkeley.edu> <1991Jun17.225245.22105@agate.berkeley.edu> Organization: D and D Data, Vienna, VA. Lines: 43 In article <1991Jun17.225245.22105@agate.berkeley.edu> et@tornado.Berkeley.EDU (Eric Thompson) writes: >On a related note, I've found that my tcsh binary (from ee.cornell.edu) >doesn't pay any attention to a "#!/bin/sh" line at the top of a Bourne >shell script. This is a pain. Since csh is a descendant of csh, which comes from the Berkeley universe, and Berkeley Unix systems have the KERNEL check for #!, you wouldn't expect csh (and tcsh) to check for it. >The workaround I've got going is to set $SHELL and $shell to /bin/sh. >Then any scripts that are executed use the $shell variable. I'd rather >if it would check the top of the script to see which shell to run--if >it's possible, let me know how, please? :-) Thanks. The usual workaround in the systems that don't check for #! is to put as the top line of the script the single character ':' for a script which needs to be run by /bin/sh (or /bin/ksh for that matter, if it has be linked to /bin/sh after MVing /bin/sh to something like /bin/sh.OLD). Csh and tcsh look at it and say "This isn't a legal command line for me, but I'll bet that old /bin/sh would love it!". At the same time, /bin/sh on some systems will pass the script to /bin/csh if the first line starts with '#'. The problem with this method is that it assumes that there are only two shells, /bin/sh, and /bin/csh. When you start tossing in other shells/interpreters/etc, things get more and more byzantine, as each needs a way to identify scripts for all others. Just look at what needs to be done for perl scripts on systems which don't check for '#!'. You don't mention which flavor of AT&T sytems you're dealing with, and my experience stops at SysVr2 (the UNIX-PC), but I believe that this still works. I think that SysVr4 has added the ability to recognize '#!' to the kernel. Some pd shells (such as ash, and maybe bash) do their own checking for '#!'. Good Luck DoN. -- Donald Nichols (DoN.) | Voice (Days): (703) 664-1585 D&D Data | Voice (Eves): (703) 938-4564 Disclaimer: from here - None | Email: --- Black Holes are where God is dividing by zero ---