Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!genrad!decvax!decwrl!pyramid!oliveb!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.unix.wizards Subject: Re: symbolic links and csh execution Message-ID: <21681@sun.uucp> Date: Sun, 21-Jun-87 17:33:47 EDT Article-I.D.: sun.21681 Posted: Sun Jun 21 17:33:47 1987 Date-Received: Tue, 23-Jun-87 00:49:51 EDT References: a7879@brl-adm.ARPA> <2211@bunker.UUCP> <1097@mtune.ATT.COM> Sender: news@sun.uucp Lines: 59 > Listen guys, if I say 'cd a/b/c/d/e;cd ..' then I am now in a/b/c/d, > regardless of how many symlinks or networked file systems I had to go > through to get there. Anything else is brain-damaged. Which can, in most cases, be done by the shell interpreting the "cd" command; the question is whether one should add extra stuff to the kernel to make this work invisibly? I tend to agree with what was given as Dennis Ritchie's position, which was "no". > On a similar note, for the people who are expounding starting one's > shell scripts with "#! /bin/csh", the logical continuation of this is > to start one's C programs with "#! /bin/cc", and so on. No. Executable files begin with a magic number, which indicates the interpreter to be used to execute that file. The "conventional" magic numbers indicate that the interpreter in question is the machine's hardware (including microcode if you have it); the "#!" magic number selects a program to be used as the interpreter. One would start C programs with "#! /usr/bin/c_interpreter" or something like that; unless one has a C interpreter, one does not normally execute C code. The intent behind "#!" was to permit *arbitrary* interpreters to run programs, not just shells. (It also permits interpreted programs to be set-UID, assuming you trust the interpreter's mechanisms to the degree necessary to make set-UID interpeted programs safe. Prior to 4.3BSD, there were two very large security holes that rendered set-UID shell scripts, at least, unsafe; those two holes were closed in 4.3BSD, but there could well be others.) > Writing a language processor which is a partial superset of an existing > standard is one thing, and quite OK in my book; hacking the kernel to > support this automagically is quite another. Huh? How does "#!" "automagically" support "...a language processor which is a partial superset of an existing standard"? What it supports is executing shell scripts as ordinary programs *without* having to ensure that all programs that might try to execute that script use "exec[lv]p" instead of "exec[lv]". The latter is somewhat nice, considering that not all programs *do* use "exec[lv]p". > Perhaps csh should have been made to interpret a strict superset of the > Bourne shell, Considering that the C shell, I believe, antedated the Bourne shell (or, at least, the public availability of the Bourne shell), this might not have been practical. > so that normal scripts work under it, and then csh scripts should have > been interpreted via "csh script"? Then we wouldn't have this problem. "#!" was not concocted merely to solve the C shell vs. Bourne shell problem. I presume DMR came up with it as a nice generalization of the notion of "executable image" and "magic number"; the cost in terms of kernel code is small, and the benefits seem to outweigh them. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com