public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Ben Schmidt <mail_ben_schmidt@yahoo•com.au>
To: git@vger•kernel.org
Subject: Further Re: Getting the path right for git over SSH
Date: Fri, 20 Jun 2008 03:13:40 +1000	[thread overview]
Message-ID: <485A93C4.3060603@yahoo.com.au> (raw)

[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.

                 reply	other threads:[~2008-06-19 17:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=485A93C4.3060603@yahoo.com.au \
    --to=mail_ben_schmidt@yahoo$(echo .)com.au \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox