Results 1 to 3 of 3
Hello all,
I can't remember the correct way to do this, I want to have a /etc/bashrc that says if there is a $user/.bashrc then use it, else use /etc/bashrc
...
- 03-12-2008 #1
if and else .bashrc help please...
Hello all,
I can't remember the correct way to do this, I want to have a /etc/bashrc that says if there is a $user/.bashrc then use it, else use /etc/bashrc
Is this close?
if [ -f $user/.bashrc ]; then
$user/.bashrc
fi
- 03-12-2008 #2
Well, let's look at what you're doing:
Your test is nearly correct. What do you believe the value of $user to be? It does not contain what you think it contains.
Also, you are saying "If this file exists, then execute it". This is not what you want: you want to source the file, not execute it.
Finally, note that after you handle the user's bashrc, you fall through on the if, and will continue to process the /etc/profile. So you will want some way to ensure that only one or the other happens.DISTRO=Arch
Registered Linux User #388732
- 03-12-2008 #3
Hi Cabhan,
My thought is this...
If there is a .bashrc file in a users home dir then use it, if not then use /etc/bashrc, just not both.
Is my thought? Is that closer?if [ -f ~/$USER/.bashrc ]; then
~/$USER/.bashrc
else
/etc/bashrc
fi


Reply With Quote