Subject: Re: How to bind keys in .kshrc
To: None <netbsd-users@netbsd.org>
From: Julien Gabel <jpeg@thilelli.net>
List: netbsd-users
Date: 10/01/2003 12:10:53
>>> The manpage for ksh(1) doesn't even mention $HOME/.kshrc. Isn't that
>>> a bug? If I used ksh, I'd like to know whether it's used for any shell
>>> or only a login shell and whether it's processed before or after
>>> $HOME/.profile etc.

>> ${HOME}/.kshrc is normally sourced if the ${ENV} variable is exported,
>> for example in the ${HOME}/.profile :
>>   ENV=${HOME}/.kshrc ; export ENV
>> This environmental script is read (sourced) each time a new sub-Korn
>> Shell process is launched : the login process is one of them.
>> ${HOME}/.kshrc is sourced *after* the ${HOME}/.profile in the login
>> phase.

> Ugggg - no wonder you have problems!

I have no problem.

> ENV is used by many shells, so you can't have ksh commands in it
> (unless you detect the shell is ksh, [ "$RANDOM" != "$RANDOM" ] is a
> check that will exclude sh)

As I know, nor the csh(1) nor the tcsh(1) uses this variable which is
used by the sh(1) compatible shells. Note that this variable is set
from ${HOME}/.profile which is even not sourced by csh(1) or tcsh(1).

Because the content of this file is sh(1) compatible, you just need - in
the case of the user uses different shells at the same time - to write
some sh(1) strict declarations.
Example : LOCALVAR="somedefinition" ; export LOCALVAR
And not : export LOCALVAR="somedefinition" which is more specific to the
Korn Shell.

######### Extract from the man of sh(1) #########
  [...]                      A login shell first reads commands from the
  files /etc/profile and then .profile if they exist.  If the environment
  variable ENV is set on entry to a shell, or is set in the .profile of a
  login shell, the shell then reads commands from the file named in ENV.
  Therefore, a user should place commands that are to be executed only at
  login time in the .profile file, and commands that are executed for every
  shell inside the ENV file.  The user can set the ENV variable to some
  file by placing the following line in the file .profile in the home
  directory, substituting for .shinit the filename desired:

        ENV=$HOME/.shinit; export ENV


######### Extract from the man of ksh(1) #########
######### @(#)PD KSH  v5.2.14 99/07/13.2 #########
  ENV   If this parameter is found to be set after any profile files are
        executed,  the  expanded value is used as a shell start-up file.
        It typically contains function and alias definitions.


--
-jg.