On Fri, Nov 01, 2002 at 12:58:24PM -0500, Stone, Timothy wrote:
> I will close by saying I'm developing a hypothesis for my best practice:
>
> ~/.bashrc should contain user aliases, functions and variables for
> the local system that builds on /etc/bashrc ~/.bash_profile should
> contain user aliases, functions and variables for remote sessions
> (needing a login shell); these environment settings should build on
> the ~/.bashrc settings or reset them based on the needs of the
> remote session.
>
> Comments and thoughts welcome.
Just my thoughts on how I handle this, since you already seem to see
the origins of the problem. I like having things I need no matter what
in .bashrc, like aliases, etc. .bash_profile invokes .bashrc:
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
The potential downside is you might have a lot of junk that is totally
unnecessary for non-interactive shells then in .bashrc. So I do:
if [ "$PS1" ]; then
. ~/.aliases
. ~/.functions
[...]
fi
This skips this stuff for non-interactive shells, but is there for
interactive shells too. This way I don't worry about login vs
non-login, or interactive vs non-interactive.
As to remote logins with ssh, etc., I use something in the
environment, like:
SSH_CLIENT=$'192.168.10.3 34655 22'
SSH_TTY=/dev/pts/3
if [ -n "$SSH_CLIENT" ]; then
# if a ssh connection
if echo $SSH_CLIENT |grep "192\.168\.10"; then
# ssh from LAN (hopefully!)
[...]
as a test whether it is remote or not.
--
Hal Burgiss
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@;redhat.com?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list