In message <3AF01797.2F39F87B at ltiflex.com>, Andy Zbikowski writes:
> Sure, you should see my config, based heavily on ^chewies...

Oh, gods.  You had to point it out that I created that monstrosity.
Yes, for a while, I was on the whole SysV rc?.d style of doing things
for my shells.  I just continually ran into problems with ssh sessions
when I used this style of sourcing rc scripts.  I had to throw in ugly
test statements like:

    # is this an SSH session?
    if [ -n $SSH_CLIENT ] ; then
        ## blah...
    fi

I know for a fact that ssh sessions and scp sessions die any time you
try to execute a program in your .bashrc and the way I had my profile
set up, in your .bash_profile.

Now-a-days, I refrain from executing programs or using the funky SysV
style directories.  I just never successfully tracked down the
problems I was having.

Anyway, to answer the question host specific rc files, Yaron's and
Andy's suggestion is the cleanest.  HOSTNAME is set by default in my
shells, but that may be an operation of pam rather than bash itself.
Regardless, you can ensure that HOSTNAME is populated by using
parameter expansion/assignment:

    # ${parameter:=word} where if parameter not populated, assign
    # word.  word is subject to command substitution, parameter
    # expansion, etc.  We use command substitution: $(command).
    ${HOSTNAME:=$(hostname)}

So your check in .bashrc would look like this:

    # test for the hostname rc file (and assign the hostname if we
    # haven't already done so
    if [ -f ${HOME}/.bashrc.${HOSTNAME:=$(hostname)} ] ; then
             . ${HOME}/.bashrc.${HOSTNAME}
    fi

If you want login specific stuff, use a ~/.bash_profile.hostname file
and place the same check in your ~/.bash_profile.  Symbolic links will
work as well, so if multiple hosts share a common setup, you can name
that ~/.bashrc.setup and link each of the hostnames to that file.

Remember, to debug things, toggle the trace option at the beginning
and end of your rc files:

    # start trace
    set -x

    # end trace
    set +x

--
Chad Walstrom <chewie at wookimus.net>                 | a.k.a. ^chewie
http://www.wookimus.net/                            | s.k.a. gunnarr
Key fingerprint = B4AB D627 9CBD 687E 7A31  1950 0CC7 0B18 206C 5AFD