Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!harpo!seismo!hao!hplabs!sri-unix!gwyn@brl-vld From: gwyn%brl-vld@sri-unix.UUCP Newsgroups: net.unix Subject: Re: Shell programming style -- a plea for better shell scripts Message-ID: <16948@sri-arpa.UUCP> Date: Sat, 25-Feb-84 19:38:37 EST Article-I.D.: sri-arpa.16948 Posted: Sat Feb 25 19:38:37 1984 Date-Received: Fri, 2-Mar-84 15:02:08 EST Lines: 28 From: Doug Gwyn (VLD/VMB)You missed the point. #!/bin/sh will be treated as a comment by the Bourne shell, so its presence cannot possibly hurt. Further, if this is NOT the first line in a Bourne shell script that is invoked by a Cshell user, the Cshell will attempt to interpret the commands, which usually results in a portion of the contents of the script actually being executed before it bombs. By having the funny first line in your Bourne shell scripts, even if a Cshell user runs one of them it will be executed correctly since the Berkeley kernel will exec /bin/sh to handle it. It is better to set the $PATH than to define explicit path names for standard UNIX system commands. For example, is "sort" in /bin in your system? It's in /usr/bin in others, except I want the one in /usr/5bin which has all the bugs fixed. When the /usr/5bin/sort is moved into /usr/bin I do not want to have to track down all the shell scripts and change "SORT=/usr/5bin/sort" to "SORT=/usr/bin/sort". By setting PATH=/usr/5bin:/bin:/usr/bin I have GUARANTEED getting the standard UNIX System V "sort" command regardless of where it actually lives, which is in different places on our different UNIX systems. An "Elements of Shell Programming Style" may be a good idea (in fact there are good guides already available in Bourne's and Kernighan & Pike's books), but you're not the one to write it..