Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!amdahl!pacbell!pbhyf!rob From: rob@pbhyf.PacBell.COM (Rob Bernardo) Newsgroups: comp.unix.wizards Subject: Re: Conditional setting of ENV in ksh - Question of how to Message-ID: <3798@pbhyf.PacBell.COM> Date: 19 Aug 88 03:04:47 GMT References: <3790@pbhyf.PacBell.COM> <10519@ulysses.homer.nj.att.com> Reply-To: rob@pbhyf.PacBell.COM (Rob Bernardo) Organization: Pacific * Bell, San Ramon, CA Lines: 38 In article <10519@ulysses.homer.nj.att.com> ekrell@hector.UUCP (Eduardo Krell) writes: +I do it in a more readable way. In my ENV file I have: + +case $- in + *i*) ... + ... +esac + +Where "..." represents whatever you want your interactive shell +to execute. +This way, you'll execute "..." only when $- (ksh's invocation flags) +contains an "i" (for interactive shell). This is one solution, but like anything, it has its minuses. In this case the newly spawned ksh has to read the entire file, even the parts it will never wind up executing. This can slow things down quite a bit when doing a simply shell escape, e.g. from vi. Someone wrote me (Thanks, Doug!) that the reason why the KSHRC array (see the orginal posting - too long to repeat it here) gets mangled is that ksh cannot correctly pass arrays to its environment. In any case, I came up with a decent solution to the problem. What I have in my .profile is the following: ENV='$HOME/.kshrc${-%%[a-hj-z]*}' # Where to find ksh stuff. # ENV file is .kshrc for non-interactive ksh invocations. # ENV file is .kshrci for interactive ksh invocations. # Presumes i flag is first if it occurs. (Btw, my .kshrci file has as its first line: . .kshrc so that all the aliases and fuctions in the latter don't need to be repeated in the former.) -- Rob Bernardo, Pacific Bell UNIX Small Bus. Systems Development & Maintenance Email: ...![backbone]!pacbell!rob OR rob@PacBell.COM Office: (415) 823-2417 Room 4E750A, San Ramon Valley Administrative Center Residence: (415) 827-4301 R Bar JB, Concord, California