Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I work on an AIX system where I have no administrator privileges. It has several shells installed, default being tcsh. I am not allowed to change the login shell. Usually I start my session from exec bash. The problem is that I do not inherit the $PATH I had in tsch. The first strange thing is that some of the entries in my $PATH are duplicated, when I do exec bash. Another strange thing is that when I do exec bash --norc and then source .bashrc everything is fine -- I get the path from tcsh and some additions from my .bashrc.

I have tried commenting out my .bashrc enirely, but it gave no result -- I still do not get the $PATH from tcsh. It seems that the system wide /etc/profile is manipulating my $PATH. I tried running exec bash --noprofile, but I still see the changes, that are introduced by /etc/profile script (which I have no control over).

So in the end perhaps someone spotted a flaw in my investigation and can tell me how to invoke bash with inhereted $PATH or can suggest a way to do it without reading the global config scripts?

(I have posted this question on superuser as well, I am not sure if it is ok, to duplicate questions, but I got no answer there, so what a heck...)

share|improve this question
    
No, it is generally not ok to cross post - this makes moderators' work harder. –  rozcietrzewiacz Dec 8 '11 at 10:31
    
It just seems this stackexchange site is less crowded, than superuser.com –  mezhaka Dec 8 '11 at 10:37
    
Do not crosspost. The right thing to do to move your question from Super User to here would have been to flag a moderator asking for the question to be migrated (but it's too late now). –  Gilles Dec 8 '11 at 20:57
2  
Don't define PATH in ~/.bashrc; see Difference between .bashrc and .bash_profile. Run exec bash -x to see what's going on when you start bash; post the trace here. –  Gilles Dec 8 '11 at 21:00

1 Answer 1

If doing source .bashrc gives you the environment you want, then what you are missing is an interactive login shell. To make bash work in that way, simply run exec bash --login or short exec bash -l.

share|improve this answer
    
Didn't do anything new. I login to my box, do some changes to my $PATH, then do exec bash --login and loose the my $PATH that was available in tcsh. –  mezhaka Dec 8 '11 at 10:36
    
Hm, so is it different from what you get after doing exec bash --norc + source .bashrc (as you've described)? –  rozcietrzewiacz Dec 8 '11 at 15:14
    
How about the same thing without exec? (that is, run just bash -l) –  rozcietrzewiacz Dec 8 '11 at 15:17
1  
exec bash --norc + source .bashrc is different from exec bash --login and exec bash --noprofile. Leaving exec out does not change anything. The other environment variables are not changed. If I setenv v hi in tcsh, then I can see it when I do echo $v in bash whichever way it was invoked it. So it is something that manipulates the environment. In man bash (as far as I read) several scripts are listed as a startup sequence (for a login shell however): /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile. Out of those only /etc/profile exists on my system. –  mezhaka Dec 8 '11 at 17:32
    
"(...) /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile. Out of those only /etc/profile exists on my system." - This means you need to create ~/.bash_profile and put [[ -f ~/.bashrc ]] && . ~/.bashrc in it. If that doesn't solve it, I will have to delete my answer as irrelevant. –  rozcietrzewiacz Dec 9 '11 at 14:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.