[comp.unix.aix] Script Environments

eravin@panix.uucp (Ed Ravin) (05/19/91)

In article <7553@spdcc.SPDCC.COM> rbraun@spdcc.COM (Rich Braun) writes:
>After installing 3.1.5, I found that I couldn't run INFO; it died
>with a syntax-error message whenever I tried to run it.

>The problem is the ENV environment variable.  The ksh shell uses this
>to identify a script to be run at startup, and info causes another
>shell to be executed.  Within this file, I had a 'set' command which
>played around with the parameters ($1 $2 etc.).  This caused info to
>die because it saw invalid parameters.

This sounds like the problem I had with both the "info" and the "xinit"
system scripts.  Both make references to ${@} or ${*}, which are not
set if you don't put parameters on the script command line.  My ksh ENV
script used to do a "set -u" since I like that for shell programming.
This caused the info/xinit scripts to bomb.

The fix should be for a script to be smart enough not to include anyone
else's environment.  The standard way to do this is to use the -p option
to suppress reading profiles and ENV scripts -- e.g. at the top of the
script:

#!/bin/ksh -p

-- 
Ed Ravin            | I'm sorry, sir, but POSTAL REGULATIONS don't allow
cmcl2!panix!eravin  | PLASTIC tape over PAPER tape and NYLON cord on an
philabs!trintex!elr | 86 inch girth to LITHUANIA...
+1 914 993 4737     |