home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.3b1
- Path: sparky!uunet!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!mdsol1!alembic!ceilidh!hijo-2!dnichols
- From: dnichols@ceilidh.beartrack.com (Don Nichols (DoN.))
- Subject: Re: tcsh question
- Message-ID: <1992Jul30.001523.8258@ceilidh.beartrack.com>
- Organization: D and D Data, Vienna Virginia
- References: <1992Jul29.141150.28545@brtph560.bnr.ca>
- Date: Thu, 30 Jul 1992 00:15:23 GMT
- Lines: 52
-
- In article <1992Jul29.141150.28545@brtph560.bnr.ca> hruska@bnr.ca (Bob Hruska) writes:
- >I am using tcsh on my 7300, it is the following version:
-
- >version tcsh 6.01.00 (Cornell) 12/19/91 options 8b,dl,al,dir
-
-
- >My question is, why can't I run any /bin/sh scripts from it?
- >If I put the #!/bin/sh at the beginning, it doesn't work.
-
- [ ... ]
-
- >If I do "sh scriptname" it works, but just "scriptname" gives
- >me "if: Expression Syntax."
-
- >Any ideas?
-
- Sure! tcsh is a csh derivitave which uses a different syntax for
- most control structures. Your "#!/bin/sh" would work in a BSD-derived
- system, or other variants as well, but not under this old a SysV. The
- ability to act on '#!' is a special case of magic number recognition done by
- the kernel. The SysV kernel that we have doesn't know about this particular
- magic number, so tcsh is left to try to figure out how to deal with the
- script, and fails.
-
- There are some examples of scripts which can tell which shell they
- are running under, and take steps to correct it. Pnews uses:
-
- ": use /bin/sh"
-
- Where the ':' character must be the first character of the file. (The rest
- is not important, except as a flag to the human examining the script.) This
- works because csh won't accept that as a pseudo-comment, but will recognize
- it as meaning that the script must be run by /bin/sh. It is not as general
- a solution as '#!' is, but it was developed back when the choices were
- /bin/sh or /wherever/csh, so if it wasnt' csh, it *must* be for sh :-)
-
- There are other ways for a perl script to recognize when it is
- running under some other shell and start up the perl interpreter, but it is
- even more ugly than this. There are *some* shells around which will do the
- '#!' interpretation on their own, but this only works if they see it before
- the wrong other shell does. Zsh claims to do this, but I haven't gotten it
- running smoothly under 3.51m yet. (It does work well under SunOs 4.1.1,
- however, which doesn't need the interpretation, since SunOs is BSD derived.
- :-)
-
- Good Luck
- DoN.
- --
- Donald Nichols (DoN.) | Voice (Days): (703) 704-2280 (Eves): (703) 938-4564
- D&D Data | Email: <dnichols@ceilidh.beartrack.com>
- I said it - no one else | <dnichols@ceilidh.aes.com>
- --- Black Holes are where God is dividing by zero ---
-