Path: utzoo!attcan!uunet!jarthur!elroy.jpl.nasa.gov!sdd.hp.com!samsung!cs.utexas.edu!execu!sequoia!uudell!mustang!jrh From: jrh@mustang.dell.com (James Howard) Newsgroups: comp.unix.questions Subject: Re: How to prevent execution of $ENV file in Korn shell scripts ? Keywords: Korn shell environment Message-ID: <10698@uudell.dell.com> Date: 4 Oct 90 23:23:30 GMT References: <392@nwnexus.WA.COM> Sender: news@uudell.dell.com Reply-To: jrh@mustang.dell.com (James Howard) Organization: Dell Computer Corp. Lines: 31 In article <392@nwnexus.WA.COM>, golder@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@mustang.dell.com Austin, TX 78759-7299