Further Re: Getting the path right for git over SSH

Previous thread: Is there a repository for git-cvsserver? by Le on Thursday, June 19, 2008 - 12:28 pm. (2 messages)

Next thread: [PATCH] t7502-commit.sh: test_must_fail doesn't work with inline environment variables by Brandon Casey on Thursday, June 19, 2008 - 1:32 pm. (8 messages)
To: <git@...>
Date: Thursday, June 19, 2008 - 1:13 pm

[Further to my previous message...]

[When starting a non-interactive non-login shell from an ssh session...]
> What bash does is source /etc/bashrc and ~/.bashrc--it evidently
> treats ssh like rsh and does a little more than is documented even for
> rsh (search for rsh in the bash man page for details).

So another, simpler, system-wide solution is to set your $PATH in
/etc/bashrc. However, this is not documented in the bash man page (which
is why I came up with the more complicated solution, as I hadn't
realised this behaviour at that stage). So I'm not sure whether it is
standard/will occur on all systems, etc.

If you're like me and like to have interactive stuff in bashrc and login
stuff in profile, you can arrange your files like this (very similar to
before, but ~/.bashrc needn't source /etc/profile now, nor do its check
with $- and grep, as /etc/bashrc does that and avoids setting $PS1).

In /etc/profile

# System-wide .profile for sh(1)
PATH=...
export PATH
# Source /etc/bashrc for interactive shells.
[ -n "$PS1" -a -r /etc/bashrc ] && source /etc/bashrc
... stuff for login shells (more environment mostly)

In /etc/bashrc

# System-wide .bashrc file for interactive bash(1) shells.
# If the shell isn't actually interactive it is an ssh session, and
# we want to source etc/profile instead.
if [ -z "$PS1" ] ; then
[ -r /etc/profile ] && source /etc/profile
return
fi
... stuff for interactive shells (aliases and terminal stuff mostly)

In ~/.profile

# For login shells (interactive or not).
# For interactive non-login shells see ~/.bashrc.
# For non-interactive non-login ssh shells see ~/.bashrc.
# For other non-interactive non-login shells see $BASH_ENV.
# At present this is sourced by ~/.bashrc for the ssh case, so
# all ssh sessions act like login sessions.
PATH=...
export PATH
...

Previous thread: Is there a repository for git-cvsserver? by Le on Thursday, June 19, 2008 - 12:28 pm. (2 messages)

Next thread: [PATCH] t7502-commit.sh: test_must_fail doesn't work with inline environment variables by Brandon Casey on Thursday, June 19, 2008 - 1:32 pm. (8 messages)