Start up files for ksh – The Korn shell .profile and .kshrc
The Korn shell (see ksh(1)) uses two startup files that allow users to customize their shell environment: a $HOME/.profile (if one exists) and the startup file specified by the ENV environment variable (if set and exported). Typically, $HOME/.kshrc is the file name used as the value of the ENV variable, however the startup file for ksh can be named any valid file name and is not constrained to be .kshrc. .kshrc is not a startup file hardcoded into ksh, but rather a common name that is used for the ksh startup file specified (optionally) by the ENV environment variable in the users environment.
The .profile is read once, by your login ksh. The ENV file is read by each invocation of ksh, if ENV is defined in the current environment. Typically, users define ENV in their .profile file, and then this variable is available to all future child shells (unless ENV is unset).
Here is the sample code
#
# Copyright (c) 1990-1998 The Santa Cruz Operation, Inc.
# All rights reserved.
#
# This Module contains Proprietary Information of the Santa Cruz
# Operation, Inc., and should be treated as Confidential.
#
PATH=$PATH:$HOME/bin:. # set command search path
export PATH
if [ -z "$LOGNAME" ]; then
LOGNAME=`logname` # name of user who logged in
export LOGNAME
fi
MAIL=/usr/spool/mail/$LOGNAME # mailbox location
export MAIL
if [ -z "$PWD" ]; then
PWD=$HOME # assumes initial cwd is HOME
export PWD
fi
if [ -f $HOME/.kshrc -a -r $HOME/.kshrc ]; then
ENV=$HOME/.kshrc # set ENV if there is an rc file
export ENV
fi
# use default system file creation mask (umask)
eval `tset -m ansi:ansi -m $TERM
${TERM:-ansi} -r -s -Q`
# If job control is enabled, set the suspend character to ^Z (control-z):
case $- in
*m*) stty susp ‘^z’
;;
esac
set -o ignoreeof # don‘t let control-d logout
case $LOGNAME in # include command number in prompt
root) PS1="!# " ;;
*) PS1="!$ " ;;
esac
export PS1
Another simple sample file: A typical .kshrc might look like this
#
# @(#) kshrc 1.1 90/03/13
#
# Copyright (c) 1990-1998 The Santa Cruz Operation, Inc.
# All rights reserved.
#
# This Module contains Proprietary Information of the Santa Cruz
# Operation, Inc., and should be treated as Confidential.
#
# If there is no VISUAL or EDITOR to deduce the desired edit
# mode from, assume vi(C)-style command line editing.
if [ -z "$VISUAL" -a -z "$EDITOR" ]; then
set -o vi
fi

Comments
No comments yet.