michaelm@bcsaic.UUCP (michael b maxwell) (01/08/86)
This is on BSD 4.2 (on a Sun, v.2.0...) I have several script files written in csh syntax that perform some tests on files. I would like to invoke them from within 'make.' The problem is that make insists on using Bourne shell...this despite the fact that the first line in the script file is #/bin/csh, and it runs in csh fine when it is called interactively. I can get around this by explicitly calling /bin/csh in the Makefile each time I want to run a script file in csh. In other words, instead of: : check.syntax : --I put in: : /bin/csh check.syntax : on each line. Obviously this is a nuisance, as well as a source of errors. And sure, I could use Bourne shell for everything, but I happen to like csh! Am I missing something? Is there a variable that can be set within the Makefile to always use /bin/csh? Or an undocumented command line option? -- Mike Maxwell Boeing Artificial Intelligence Center ...uw-beaver!uw-june!bcsaic!michaelm
wiener@idacrd.UUCP (Matthew P Wiener) (01/12/86)
> This is on BSD 4.2 (on a Sun, v.2.0...) > I have several script files written in csh syntax that perform some tests on > files. I would like to invoke them from within 'make.' The problem is that > make insists on using Bourne shell...this despite the fact that the first line > in the script file is #/bin/csh, and it runs in csh fine when it is called > interactively. Have your system manager recompile make: somewhere in the source is a line that checks your environmental variable $SHELL. For some reason that line is usually commented out, even in BSD. berkeley!brahms!weemba Matthew P Wiener Math Dept UCB Berkeley CA 94720
rob@ptsfb.UUCP (Rob Bernardo) (01/13/86)
In article <125@idacrd.UUCP> wiener@idacrd.UUCP (Matthew P Wiener) writes: >> This is on BSD 4.2 (on a Sun, v.2.0...) >> I have several script files written in csh syntax that perform some tests on >> files. I would like to invoke them from within 'make.' The problem is that >> make insists on using Bourne shell...this despite the fact that the first line >> in the script file is #/bin/csh, and it runs in csh fine when it is called >> interactively. > >Have your system manager recompile make: somewhere in the source is a >line that checks your environmental variable $SHELL. For some reason >that line is usually commented out, even in BSD. > Once I had the "opposite" problem. I was using csh(1) as my login shell, but the Makefile I often used required use of sh(1). I added the variable definition SHELL=/bin/sh to the Makefile. This way, only the shell used by make(1) was affected, leaving the environment of my login shell alone. This may be a different version of make(1) than on the Sun/BSD 4.2, though, being something of a SYSV Unix(tm) on a Convergent Technologies MegaFrame(tm).
michaelm@bcsaic.UUCP (michael b maxwell) (01/14/86)
Thanks to all who pointed out to me that the reason "make" refused to use cshell in script files it called is that the first line of the script file should read: #!/bin/csh --I had used: #/bin/csh incorrect!! Strange, I couldn't find this in the documentation I have, although I probably didn't look far enough. Indeed, the documentation seemed to imply that *any* comment starting at the first character of a file would cause the script file to be run in csh, surely a strange practice... And #/bin/csh worked everywhere that I tried it, until I tried make. (Leaving it out would result in the same file being run by sh.) Why is make different? A few observed that "make" should look at the SHELL variable. It doesn't on our system (BSD 4.2), and a note today in news from Matthew P Wiener (of the Math Dept at UCB) says that the line in "make" that checks SHELL is usually commented out in the BSD version. Anybody know why? -- Mike Maxwell Boeing Artificial Intelligence Center ...uw-beaver!uw-june!bcsaic!michaelm
chris@globetek.UUCP (chris) (01/15/86)
>In article <125@idacrd.UUCP> wiener@idacrd.UUCP (Matthew P Wiener) writes: > This is on BSD 4.2 (on a Sun, v.2.0...) > I have several script files written in csh syntax that perform some tests on > files. I would like to invoke them from within 'make.' The problem is that > make insists on using Bourne shell... At least one make I know of (on a pseudo-Berkeley system) looks for MAKESHELL in the environment -- you could see whether yours does too. -- Christine Robertson {linus, ihnp4, decvax}!utzoo!globetek!chris Money may not buy happiness, but misery in luxury has its compensations...
guy@sun.uucp (Guy Harris) (01/16/86)
> >Have your system manager recompile make: somewhere in the source is a > >line that checks your environmental variable $SHELL. For some reason > >that line is usually commented out, even in BSD. > > Once I had the "opposite" problem. I was using csh(1) as my login shell, > but the Makefile I often used required use of sh(1). I added the variable > definition > > SHELL=/bin/sh > > to the Makefile. This way, only the shell used by make(1) was affected, > leaving the environment of my login shell alone. Which is probably why the line in question was commented out in the 4.2BSD "make". Anybody know whether it was there in V7? V7 didn't have a SHELL environment variable, to my knowledge, so I presume it was added in 4.xBSD. > This may be a different version of make(1) than on the Sun/BSD 4.2, though, > being something of a SYSV Unix(tm) on a Convergent Technologies > MegaFrame(tm). The reason it's *not* commented out in the System V (and System III) "make", I'm told by somebody from AT&T, is that it was intended for Korn shell users. The Korn shell, unlike the C shell, is a (either completely or mostly) compatible superset of the Bourne shell, so it doesn't break Makefiles the way using the C shell does. (S3/S5 also has a SHELL environment variable). Guy Harris
guy@sun.uucp (Guy Harris) (01/16/86)
> > This is on BSD 4.2 (on a Sun, v.2.0...) > > I have several script files written in csh syntax that perform some tests > > on files. I would like to invoke them from within 'make.' The problem > > is that make insists on using Bourne shell... > > At least one make I know of (on a pseudo-Berkeley system) looks for > MAKESHELL in the environment -- you could see whether yours does too. It doesn't - Sun didn't put that in. Whatever system you saw, its makers probably added that feature, 'cause it's not in 4.2BSD. Guy Harris
guy@sun.uucp (Guy Harris) (01/16/86)
> Strange, I couldn't find this (#! /bin/csh) in the documentation I have, > although I probably didn't look far enough. It's done by the kernel, so check EXECVE(2) in the System Interface Manual (which is what Sun calls sections 2, 3, 4, and 5). > Indeed, the documentation seemed to imply that *any* comment starting at > the first character of a file would cause the script file to be run in csh, > surely a strange practice... And #/bin/csh worked everywhere that I tried > it, until I tried make. (Leaving it out would result in the same file > being run by sh.) Why is make different? Yes, it is a strange practice. A little bit of the history behind it: The original V7 shell (and the V6 shell, as well - I think the C shell first appeared under V6) handled "comments" with a command called ":". This command didn't do anything, so it "threw out" what followed it. (However, what followed it had to be syntactically legal, and if it happened to include I/O redirection, the I/O redirection was done anyway.) The C shell supported real comments; a "#" anywhere on a line caused the scanner to ignore the rest of the line. The creators of the C shell wanted to have a way for the C shell to recognize regular shell scripts, and *vice versa*. This was so that you could write scripts for either shell and have it be executed by the correct shell, no matter what shell you were running. The "#!" feature in the kernel didn't exist at that point, so they couldn't use it. They decided that any script which began with a regular shell comment - i.e., the first character of the script was ':' - was a regular shell script, and any script that began with a C shell comment - i.e., the first character of the script was '#' - was a C shell script. Since then, the '#!' stuff was put into 4BSD (and maybe 2.9BSD), so the old rules aren't necessary. Those rules aren't too cool any more, either, since the Bourne shell in 4.xBSD and in Systems III and V support the same comment style as the C shell, so "if it begins with '#' it's a C shell script" simply isn't true anymore (especially if it begins with "#! /bin/sh"!). The reason "make" is different is that "make" doesn't always run its command lines from the shell - if the command line doesn't have anything on it that requires the use of the full shell (i.e., no shell metacharacters), it runs the command itself to speed things up. "make", unlike the Bourne and C shells, doesn't have the ':' vs. '#' rule built into it, so it runs *everything* with the same shell, which is the Bourne shell (unless your "make" uses the SHELL make/environment variable). > A few observed that "make" should look at the SHELL variable. It doesn't > on our system (BSD 4.2), and a note today in news from Matthew P Wiener > (of the Math Dept at UCB) says that the line in "make" that checks SHELL > is usually commented out in the BSD version. Anybody know why? For a good guess at why - and for an explanation of why "make" should NOT look at the SHELL variable - see my response to Rob Bernardo's posting on this subject. Guy Harris
rwl@uvacs.UUCP (01/18/86)
> I have several script files written in csh syntax that perform some tests on > files. I would like to invoke them from within 'make.' The problem is that > make insists on using Bourne shell...this despite the fact that the first line > in the script file is #/bin/csh, and it runs in csh fine when it is called > interactively. > : > Am I missing something? Is there a variable that can be set within the > Makefile to always use /bin/csh? Or an undocumented command line option? Yeah, you are missing something. The magic cookie that defines the interpreter the system should choose when executing a shell script is "#!"; these characters should be the first two bytes of the file. What you should say at the top of your script is #! /bin/csh not just #/bin/csh which would not be interpreted by the kernel as anything meaningful and would be interpreted as a comment in either sh(1) or csh(1). It's not that make(1) is insisting on using the Bourne shell to interpret the file, just that Unix will use sh(1) as the interpreter when it doesn't know what else to use. Unless you actually need your usual aliases within the script, I'd recommend using the form #! /bin/csh -f which will start up faster because it refrains from reading ~/.cshrc. -- Ray Lubinsky University of Virginia, Dept. of Computer Science uucp: decvax!mcnc!ncsu!uvacs!rwl
mjl@ritcv.UUCP (Mike Lutz) (01/18/86)
In article <431@bcsaic.UUCP> michaelm@bcsaic.UUCP (michael b maxwell) writes: > >A few observed that "make" should look at the SHELL variable. It doesn't on >our system (BSD 4.2), and a note today in news from Matthew P Wiener (of the >Math Dept at UCB) says that the line in "make" that checks SHELL is usually >commented out in the BSD version. Anybody know why? Well, we had "make" look at the SHELL environment variable, and it is a mixed blessing at best. The basic problem is that "shell independent" makefiles are difficult to write once you get beyond the simplest commands. If programmer "C", who uses CSH, writes a makefile, little things like ">&" will creep in to the commands. When programmer "B", a Bourne shell user, trys to use the makefile, all hell breaks lose. So I advocate strict adherence to BSH -- if you really need CSH, invoke it explicitly (and realize that you may have just destroyed the portability of your makefile). Mike Lutz -- Mike Lutz Rochester Institute of Technology, Rochester NY UUCP: {allegra,seismo}!rochester!ritcv!mjl CSNET: mjl%rit@csnet-relay.ARPA
wcs@ho95e.UUCP (#Bill.Stewart.2G202.x0705) (01/18/86)
> A few observed that "make" should look at the SHELL variable. It doesn't > on our system (BSD 4.2), and a note today in news from Matthew P Wiener > (of the Math Dept at UCB) says that the line in "make" that checks SHELL > is usually commented out in the BSD version. Anybody know why? It's fine for "make" to use the *Makefile author's* $SHELL if he/she wants to use it, but using $SHELL means it uses the shell of the *person making the software* If make always uses /bin/sh, then everyone can use it. If a given makefile specifies csh, then 2/3 of the UNIX systems out there can use it, but they can use it reliably. If the makefile uses $SHELL, then any of you who use /bin/sh can't make software written by a csh user, and csh users can't make software written by a /bin/sh user, even if they have both shells on there machine. I normally use ksh, but stick to the /bin/sh subset for programming. How many of you still have the "Adventure Shell" on your system that someone (Doug Gwyn or Guy Harris?) posted a few years ago? Will it work with make? :-) "A nasty little dwarf throws a stone knife into your mailbox!" n You are in small, seldom-used directory There is a makefile here There is a foo.c here attack foo.c with "make" -- # Bill Stewart, AT&T Bell Labs 2G-202, Holmdel NJ 1-201-949-0705 ihnp4!ho95c!wcs
gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (01/19/86)
> How many of you still have the "Adventure Shell" on your system that someone > (Doug Gwyn or Guy Harris?) posted a few years ago? Will it work with make? :-) Mea culpa. It's still available, although it could stand improvement. Various other sites have enhanced it or converted it to C. (The original version was a huge Bourne shell script. It was a lot easier to write a shell using another shell to do the hard stuff.)
wls@astrovax.UUCP (William L. Sebok) (01/20/86)
>> How many of you still have the "Adventure Shell" on your system that someone >> (Doug Gwyn or Guy Harris?) posted a few years ago? Will it work with make? :-) >Mea culpa. It's still available, although it could stand improvement. >Various other sites have enhanced it or converted it to C. Where can I get the C version? I need it for use with make. :-) -- Bill Sebok Princeton University, Astrophysics {allegra,akgua,cbosgd,decvax,ihnp4,noao,philabs,princeton,vax135}!astrovax!wls