Path: utzoo!attcan!uunet!zephyr.ens.tek.com!uw-beaver!sumax!nwnexus!golder From: golder@nwnexus.WA.COM (Warren Jones) Newsgroups: comp.unix.questions Subject: How to prevent execution of $ENV file in Korn shell scripts ? Keywords: Korn shell environment Message-ID: <392@nwnexus.WA.COM> Date: 4 Oct 90 15:49:59 GMT Organization: Golder Associates Lines: 46 When writing a C shell script, you can start off with: #! /bin/csh -f ... where the "-f" flag insures that the user's $HOME/.cshrc file is not read. Efficiency is a secondary consideration here. More important is making sure that the shell environment is predictable, and that you don't unwittingly use an alias that was defined in .cshrc. Does anyone know a way to avoid reading the user's $ENV file in Korn shell scripts? I'm puzzled that a shell with so many features apparently neglects this question. Of course, you can always make the behavior of a script predictable by writing all commands as fully qualified pathnames (e.g. "/bin/sed", rather than just "sed"). But: 1. This is tiresome to write and makes scripts hard to read. 2. Who wants to have to remember which commands are in /bin, which are in /usr/bin, and which are in /usr/ucb ? (Do you have some other directories on your system ?) 3. I suspect that the distribution of commands among these directories is not portable between various flavors of **ix. Suggestions? A related question: When working on an HP-UX system a while back, I remember seeing in one of the manuals a trick for defining ENV so that the variable expands to the desired file name for interactive shells, but to a null string if the shell is not interactive. NOTE: this is a different question, and does involve efficiency (though I'm sure not in any critical way). After all, you don't need to read the ENV file when the shell is simply being used to glob some file names for an editor. The trick involved checking the "$-" flags variable for the presence of the letter "i" (indicating an interactive shell). I remember marveling at the time how wonderfully obscure and arcane it was, but I can't quite seem to reproduce it. Can anyone out there provide the answer? -- ---------------------------------------------------------------- Warren Jones Golder Associates Inc. (uucp: uunet!nwnexus!golder) 4104 148th Avenue NE (206) 883-0777 Redmond, WA 98052, USA