Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: # not honored? Message-ID: <3099@auspex.auspex.com> Date: 29 Mar 90 20:13:20 GMT References: Organization: Auspex Systems, Santa Clara Lines: 54 >But I had thought that "#" as the first byte of a file meant "this is >a C shell script" (unless, of course, the first two bytes are "#!"). That's true on some systems. It is not true on others, and SunOS since SunOS 3.0 has been one of the "others". >It appears that the Bourne shell does not respect this rule. That is correct. >Should it? No. The original V7 Bourne shell didn't really have comments; instead, it had a no-op command ":", that permitted you to give it arguments (as long as they were syntactically correct and didn't have unpleasant side-effects!) that took the form of descriptive text. The C shell (either *ab initio*, or after some point in its life), *did* have comments, marked with "#". The original systems on which the C shell appeared didn't support "#!", so the ": means Bourne shell, # means C shell" crock was invented as a way of having Bourne shell users able to run C shell scripts and *vice versa*. Then "#!" appeared, which obliged the Bourne shell to be able to cope with "#" as the first character in a script. Berkeley added "#" as a real comment character in the Bourne shell, but didn't change the aforementioned crock. AT&T *also* added "#" as a comment character in the Bourne shell; since they didn't much use the C shell, they didn't add said crock. SunOS 3.0 picked up the S5R2 Bourne shell, since it's a big improvement over the V7-vintage one in BSD. Given that "#!" had been around for a while, it was perhaps concluded (I wasn't involved at the time, so I don't know for sure) that said crock had outlived its usefulness. >(On systems where the C shell exists and uses this convention.) S5R4 is such a system, and all *hell* would break loose were the Bourne shell to adopt that convention, since "#" has been a comment character for quite a while, and plenty of scripts would break horribly were that convention to be adopted. Fortunately, S5R4 has "#!", so that convention isn't needed, either.... The moral of the story is that the best thing to do at this point is probably to blow off the systems that don't have "#!", and always use "#!" to indicate the interpreter to be used to handle a script. An even better thing to do might be to think twice before deciding to write a script in the C shell; the Bourne shell is generally accepted as handling scripts better....