1834166 Members
3054 Online
110064 Solutions
New Discussion

ENV= kshrc

 
SOLVED
Go to solution
jerry1
Super Advisor

ENV= kshrc

Can any tell me what this default ENV statement
does?

START=$HOME/.kshrc
ENV=${START[(_$-=1)+(_=0)-(_$-!=_${-%%*i*})]}

As opposed to just using ENV=$HOME/.kshrc.
2 REPLIES 2
c_51
Trusted Contributor
Solution

Re: ENV= kshrc

the result is that your .kshrc is sourced only if the shell being run is interactive. If the shell isn't interactive the .kshrc file isn't sourced.

it is explained in more detail in an HP shell manual:

http://docs.hp.com/en/B2355-90046/ch23s02.html
jerry1
Super Advisor

Re: ENV= kshrc

This is not working out for me.

Here is the doc info below. But like the
example below. I get an echo output for both
[0] and [1] which may explain why on some
non interactive scritps I get the stty: Not a
typewriter. message. Also get ": ( :" not
set. If the session is interactive then it
works.

----------------------------
You can turn off the processing of the ENV file for noninteractive shells with the following in your ~/.profile:


export ENV='${FILE[(_$-=1)+(_=0)-(_$-!=_${-%%*i*})]}'
export FILE=$HOME/.envfile


The idea behind this scheme is to set up an array (FILE) whose first element is the file we want executed at startup, and whose second element is null.


$ export FILE=$HOME/.envfile
$ echo $FILE[0]/users/pbm/.envfile
$ echo $FILE[1]
$

-------------------------------------

Can anyone give more info on the use of this
function and does anyone have any good
way to set the DISPLAY. I am using the
following below in .profile. Two tests
because sun has different output with "who"
command. These statements are also giving
problems with NCD xterm booting of .xsession
file.

if [ "`uname -s`" = "HP-UX" ];then
DISPLAY=`/usr/bin/who -mR | awk '{print $6}' | sed -e "s/(//" -e "s/)//"`:0.0
else
DISPLAY=`/usr/bin/who -m | awk '{print $6}' | sed -e "s/(//" -e "s/)//"`
fi
export DISPLAY