Further Re: Getting the path right for git over SSH

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[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
     # Source ~/.bashrc for interactive shells.
     if [ -n "$PS1" -a -r ~/.bashrc ]; then source ~/.bashrc ; fi
     ... stuff for login shells (more environment mostly)

   In ~/.bashrc

     # For interactive non-login shells
     # and non-interactive non-login ssh shells.
     # For login shells (interactive or not) see first existent of
     # ~/.bash_profile, ~/.bash_login and ~/.profile.
     # For other non-interactive non-login shells see $BASH_ENV.
     # At present, this is sourced by ~/.profile so runs for all
     # interactive shells (login or not).
     # If the shell isn't actually interactive it is an ssh session, and
     # we want to source ~/.profile instead.
     if [ -z "$PS1" ] ; then
       source ~/.profile
       return
     fi
     ... stuff for interactive shells (aliases and terminal stuff mostly)

Ben.


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux