shell behaves differently in rl5 and rl3
Hi I'm running rh9.0 and at the moment I am playing with sed. I have put a function in my .bash_profile so that it would be available and not have to be declared every session. However the function only runs in rl3 at the shell prompt
In rl5 typing in the function name and arguments just returns me to the prompt no error message nothing. In rl5 I'm using xterm and rh default terminal program. any help appreciated. WD |
G'day mate :}
Create a .bashrc and source .bash_profile from there. Alternatively, invoke as "xterm -ls" to make it a login shell ... if you want to understand why, read Code:
man bash Cheers, Tink |
thanks Tink, is there a way to set bash to start with "bash --login" so I dont have to type it in every time? same with xterm -ls.
Can I put "bash --login" in my .bashrc file? WD |
You could do that, but I personally just redirect my .bash_profile to .bashrc -- the following are the contents of my .bash_profile:
Code:
if [ -r ~/.bashrc ] |
Yeah I have something similar in my .bash_profile
if [ -f ~/.bashrc ] ; then . ~/.bashrc fi |
You need it the other way round mate, since
.bash_profile won't be pulled if it's not a login shell which in your case it isn't. If it's NOT a login-shell bash only evaluates ~/.bashrc Cheers, Tink |
slight problem, I put "bash --login" in my .bashrc file and now I can't login as root :eek:
nor can I su - root from other user any suggestions... yes I know I shouldn't have been working in root :o my .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin:$HOME/bob/bin BASH_ENV=$HOME/.bashrc USERNAME="root" export USERNAME BASH_ENV PATH function testfind () { echo "first argument: $1" echo "second argument: $2" sed -n "/$1/p" $2 } My .bashrc # .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' alias ls='ls --color=yes' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi bash --login WD |
Boot into single user mode and edit it from there ...
If that fails, boot of CD (rescue mode). Other (possbile) work-around: su -c "mv ~/.bashrc ~/.bashrc.bad" Cheers, Tink |
booting to rl3 doesnt work can't login as root
dont I need to be root to do the mv? |
Just try it :) It's all one line!
I won't f*ck up root account just to verify that it works ;} Cheers, Tink |
LOL
OK it worked:D still leaves me with ny original problem... and both .bashrc and .bash_profile have if [ -f ~/.bashrc ] ; then . ~/.bashrc fi so it shouldn't matter wether the shell is interactive or login WD |
OK, let's get that straight ...
:} You need to source .bash_profile from .bashrc for the modifications in .bash_profile to be working in the xterm. Sourcing .bashrc from both .bashrc and .bash_profile won't give you any benefit. If it's not a login shell .bash_profile won't be pulled at all. Cheers, Tink P.S.: I think I definitely deserve an affero after all this ;) |
OK affero done.
I understand what you mean by source .bash_profile and why, I,m not sure how. Do I replace... in .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi with # Source global definitions if [ -f ~/.bash_profile ]; then ~ /.bash_profile fi ??? WD |
Got that right :)
Cheers, Tink |
Ok I tried..
# Source global definitions if [ -f ~/.bash_profile ]; then . ~ /.bash_profile fi no luck, and login failed and.. source ~/.bash_profile no luck, and login failed and.. ln -s /home/bob/.bashrc /home/bob/.bash_profile this gave message ln : `/home/bob/.bash_profile': file exists but login didn't fail but also didn't achieve desired result. I have done quite a bit of googling and this seems to have been aproblem for a few people but the solution never seems to be arrived at :scratch: WD |
All times are GMT -5. The time now is 01:07 AM. |