Conditional setting of ENV in ksh - Question of how to
Rob Bernardo
rob at pbhyf.PacBell.COM
Fri Aug 19 13:04:47 AEST 1988
In article <10519 at ulysses.homer.nj.att.com> ekrell at 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 at PacBell.COM
Office: (415) 823-2417 Room 4E750A, San Ramon Valley Administrative Center
Residence: (415) 827-4301 R Bar JB, Concord, California
More information about the Comp.unix.wizards
mailing list