On Mon, Jan 20, 2003 at 11:07:16AM +0530, Rahul Kumar wrote:
>  I mean only single user, with many terminals open. i didnt want to keep
>  executing bash_profile in each window. some settings in my bash_profile
>  are appended, so re-executing it creates a problem.
>  
>  Anyway, it seems from some replies that its not possible. Thanks.

There are workarounds, of course.

1. export PROMPT_COMMAND='source $HOME/.bashrc' so that bash will re-read
the file before issuing a prompt (will get pretty slow if you have a
largeish .bashrc).

2. To overcome the problem of settings getting appended, you need to have
related checks in your .bashrc. One way of making sure that a block will
get executed only while logging in for the first time is to set a special
variable in /etc/profile and unset it at the end of your own .bashrc.

In /etc/profile:
if [ $SHLVL -eq 1 ]; then # Or use $PPID here. Not sure which one.
   EXECUTEONCE=true
fi

In .bashrc:
if [ -n "$EXECUTEONCE ]; then
   # Stuff that should be executed only at startup
fi

... # Rest of the stuff.

# This should be the last line of .bashrc
unset EXECUTEONCE 

3. I use this block to get rid of duplicate PATH entries. You can adjust it for
MANPATH, CLASSPATH etc.

PATH=$(echo $PATH | awk -F: '
    {
    for (i = 1; i <= NF; i++)
        arr[$i];
    }
    END {
    for (i in arr)
        printf "%s:" , i;
        printf "\n";
    } ')
export PATH

Binand

PS: Standard Disclaimers apply.

-- 
Russian Roulette with Unix:
while :; do kill $RANDOM &> /dev/null && break || sleep 1; done


-------------------------------------------------------
This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your  SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
_______________________________________________
linux-india-help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/linux-india-help

Reply via email to