How to prevent execution of $ENV file in Korn shell scripts ?

James Howard jrh at mustang.dell.com
Fri Oct 5 09:23:30 AEST 1990


In article <392 at nwnexus.WA.COM>, golder at nwnexus.WA.COM (Warren Jones) writes:
> 
> 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?
> 

export FILE=$HOME/.kshrc
# Define the ENV variable only when interactive.
#       If $ENV is defined, it is the name of the file which
#       contains further commands which customize the ksh environment.
#       If ksh isn't running interactively, there's no need to
#       run these commands.
ENV='${FILE[(_$-=0)+(_=1)-_${-%%*i*}]}'

This is pretty much straight out of the Korn book..


James Howard        Dell Computer Corp.        !'s:uunet!dell!mustang!jrh
(512) 343-3480      9505 Arboretum Blvd        @'s:jrh at mustang.dell.com
                    Austin, TX 78759-7299   



More information about the Comp.unix.questions mailing list