Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a
virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month.
Click here for more info.
09-21-2004, 02:21 PM
#1
Member
Registered: Jun 2004
Location: New Zealand
Posts: 60
Rep:
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
09-21-2004, 02:54 PM
#2
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
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
/INVOCATION
Cheers,
Tink
09-21-2004, 03:38 PM
#3
Member
Registered: Jun 2004
Location: New Zealand
Posts: 60
Original Poster
Rep:
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
Last edited by Warmduvet; 09-21-2004 at 03:39 PM .
09-21-2004, 04:19 PM
#4
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290
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 ]
then
. ~/.bashrc
fi
and then I put all of my customized setup stuff into my .bashrc file. This way it gets run regardless of whether or not I'm invoking a login shell.
09-21-2004, 04:43 PM
#5
Member
Registered: Jun 2004
Location: New Zealand
Posts: 60
Original Poster
Rep:
Yeah I have something similar in my .bash_profile
if [ -f ~/.bashrc ] ; then
. ~/.bashrc
fi
Last edited by Warmduvet; 09-21-2004 at 04:51 PM .
09-21-2004, 05:02 PM
#6
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
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
09-21-2004, 07:04 PM
#7
Member
Registered: Jun 2004
Location: New Zealand
Posts: 60
Original Poster
Rep:
slight problem, I put "bash --login" in my .bashrc file and now I can't login as root
nor can I su - root from other user any suggestions...
yes I know I shouldn't have been working in root
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
Last edited by Warmduvet; 09-21-2004 at 07:13 PM .
09-21-2004, 07:12 PM
#8
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
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
Last edited by Tinkster; 09-21-2004 at 07:13 PM .
09-21-2004, 07:15 PM
#9
Member
Registered: Jun 2004
Location: New Zealand
Posts: 60
Original Poster
Rep:
booting to rl3 doesnt work can't login as root
dont I need to be root to do the mv?
09-21-2004, 07:17 PM
#10
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Just try it :) It's all one line!
I won't f*ck up root account just to verify that
it works ;}
Cheers,
Tink
09-21-2004, 07:22 PM
#11
Member
Registered: Jun 2004
Location: New Zealand
Posts: 60
Original Poster
Rep:
LOL
OK it worked
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
Last edited by Warmduvet; 09-21-2004 at 10:15 PM .
09-21-2004, 07:38 PM
#12
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
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 ;)
09-21-2004, 09:15 PM
#13
Member
Registered: Jun 2004
Location: New Zealand
Posts: 60
Original Poster
Rep:
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
09-21-2004, 10:07 PM
#14
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Got that right :)
Cheers,
Tink
09-22-2004, 12:09 AM
#15
Member
Registered: Jun 2004
Location: New Zealand
Posts: 60
Original Poster
Rep:
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
WD
All times are GMT -5. The time now is 08:49 PM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News