Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!oliveb!intelca!mipos3!merlyn
From: merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge)
Newsgroups: comp.unix.wizards
Subject: Re: Conditional setting of ENV in ksh - Question of how to
Message-ID: <2748@mipos3.intel.com>
Date: 18 Aug 88 20:37:55 GMT
References: <3790@pbhyf.PacBell.COM>
Sender: nobody@mipos3.intel.com
Reply-To: merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge)
Organization: Stonehenge; netaccess via BiiN, Hillsboro, Oregon, USA
Lines: 44
In-reply-to: rob@pbhyf.PacBell.COM (Rob Bernardo)

In article <3790@pbhyf.PacBell.COM>, rob@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
 or ...!tektronix!inteloa[!intelob]!merlyn
Standard disclaimer: I *am* my employer!