Conditional setting of ENV in ksh - Question of how to
Randal L. Schwartz @ Stonehenge
merlyn at intelob.intel.com
Fri Aug 19 06:37:55 AEST 1988
In article <3790 at pbhyf.PacBell.COM>, rob at pbhyf (Rob Bernardo) writes:
|
| In one of the earlier guides to ksh, I found any interesting way
| to set the ENV variable so that your ENV file gets read
| only by *interactive* invocations of ksh (which reduces a lot of
| overhead when doing shell escapes and whatnot). The solution
| was the following:
[ long details omitted ... ]
| 2. How do I solve what I originally set out to do - namely, have ENV
| set to one file for all interactive ksh invocations and set to a
| different file for all non-interactive ksh invocations?
Here's what I do:
.profile contains:
ENV=$HOME/.kshrc; export ENV
$HOME/.kshrc contains:
. $ENV.host
case X$- in
*i* )
. ${ENV}i
;;
*)
## NON INTERACTIVE SHELL ONLY ##
;;
esac
and $HOME/.kshrci contains my interactive shell stuff. If you added
". ${ENV}u" where it says "NON INTERACTIVE SHELL" above, you could
source your other file instead, calling it "$HOME/.kshrcu". (I don't
have a need for that, but the hooks are there.)
This stuff is all pretty fast, because the "case" doesn't fork a
shell. The reason I don't just put the .kshrc stuff in .profile is
that I don't want a /bin/sh to interpret it, just a /bin/ksh.
Hope this helps...
--
Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095
on contract to BiiN Technical Publications (for now :-), Hillsboro, Oregon
<merlyn at intelob.intel.com> or ...!tektronix!inteloa[!intelob]!merlyn
Standard disclaimer: I *am* my employer!
More information about the Comp.unix.wizards
mailing list