Hi guys...
I have a ksh shell by default, so when I login to my unix box, all my .profile statements gets executed(including the aliases).
But for some reasons(may be not comfortable using ksh), I would always switch to BASH(in the same session but as a child process) but in the process I am loosing all the aliases which were active in my parent (ksh)...
I understand that by typing BASH at the cmd line, I am starting a child process which should atleast inherit the charateristics(aliases etc) of the immediate parent....But in this case, its not happening.
Can somebody explain me this scenario?...and If there is a best(minimal) way to have the similar behavior as the parent, what would that be?...
PS: Please don't advice to DOT the profile once again !
Thanks for the input.
Could you please eloberate on this command?..I need to know what exactly I
[ -x /path/to/bash ]&&exec /path/to/bash -l
am doing here...
-x checks if you have permission to execute the file (the bash shell in this case), if the test returns true, substitutes (the exec builtin) your current shell with bash run as a login shell (the -l switch).
Thx...
Does this substitution pre-vail multiple sessions?....or
when I log out of the current session, the login shell will be back to KSH again?..which means I am dealing with a single session ONLY with out effecting other developers !!!
If you put that command in .profile it will affect everyone using that initialization file (the same username). If you put that in .kshrc or whatever file you use for your interactive sessions, it will affect all interactive sessions that use that rc file.
Alright...I see your suggestion here...
But, I don't have any .kshrc(or any kind of such interactive programs) in my HOME which forces me to change the .profile.
Sorry....thats my bad....bash file exists in /usr/bin.
but when I execute your cmd, just the statement (AS IT IS) goes into .kshrc and there is no execution.
When I execute .kshrc alone with the command inside it, the session completely exits.
Yep,
just tried this on an old Solaris machine and it works
Create an empty .bash_profile.
The existence of this file will prevent the exec'd bash from trying to
read ~/.profile, and re-executing itself over and over again.
touch "$HOME"/.bash_profile
Execute the following command:
printf "%s\n" '[ -x /usr/bin/bash -a "$PS1" ]&&exec /usr/bin/bash --login'>>"$HOME"/.profile
Leave your current session open, start a new one (.profile is read only on logon, so if you open a new session from the same terminal, that won't work).
Cool...
but b4 executing this, I want to make sure that we are getting step 2 right..
Are you trying to throw the o/p of step 2 to .profile or .bash_profile?..
I dont want to touch the existing profile...right?...
You should modify the existing profile (note the >> append redirection).
I cannot get my old ksh88 to read .kshrc ...
That's why I added the test for interactive shell $PS1, to simulate the rc behavior.
You should:
Create an empty(for now:)) .bash_profile.
Modify your existing .profile (make a backup copy first).