bash shell - where does it set PATH?

Discussion in 'Mac Programming' started by toddburch, May 9, 2008.

  1. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #1
    I want to modify my default PATH for the default shell in Terminal. Can't figure out where the .profile or _login files are on Tiger.

    Thanks!
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    By default your user doesn't have a .profile. The system one gets used. But if you add a .profile to your ~ directory then it'll get used...
     
  3. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    The bash man page indicates that it should be at /etc/profile

    And it is :) I'd really not recommend changing it though
     
  5. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #5
    Not going to change that one - just getting my head around unix. Thanks!

    Todd
     
  6. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #6
    Ah - it's not called .profile, but profile. Got it!
     
  7. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #8
    Interesting. I installed JRUBY some time ago and its install modified /etc/profile to set an env. variable (JRUBY_HOME) and it modifies the path there to include its own bin path.

    Code:
    # System-wide .profile for sh(1)
    
    JRUBY_HOME="/Users/toddburch/jruby-1.0.1"
    
    PATH="/bin:/sbin:/usr/bin:/usr/sbin:$JRUBY_HOME/bin"
    export PATH
    
    if [ "${BASH-no}" != "no" ]; then
            [ -r /etc/bashrc ] && . /etc/bashrc
    fi
    
    Is that poor form?
     
  8. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #9
    Yes! Exceedingly poor form.

    Code:
    yellow$ more profile 
    # System-wide .profile for sh(1)
    
    if [ -x /usr/libexec/path_helper ]; then
            eval `/usr/libexec/path_helper -s`
    fi
    
    if [ "${BASH-no}" != "no" ]; then
            [ -r /etc/bashrc ] && . /etc/bashrc
    fi

    Then in your ~/.bash_profile or ~/.profile:

    Code:
    PATH=$PATH[COLOR="RoyalBlue"]:/usr/local/bin:/sw/bin:/sw/sbin:/Developer/Tools:/usr/X11R6/bin[/COLOR]
    export PATH
    
    Where the stuff in blue is the modified PATH.
     
  9. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #10
    OK, thanks yellow. I'll digest this, and a bit of the bash syntax (I have a book) and fix things up accordingly.

    Is that "path_helper" something you put together?
     
  10. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #12
    I see - that's why my Tiger man page didn't turn up anything!
     
  11. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #13
    I was afraid you might have Tiger, but figured not when I looked at your profile and saw that you had a fat MP. My bad. :)
     
  12. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #14
    I'll eventually upgrade to leopard when some key software I use resolves the issues it has with Leopard.
     
  13. voodoojello macrumors newbie

    Joined:
    May 9, 2008
    Location:
    Nowhere
  14. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #16
    That's bad form. There's no reason that every bash shell opened on the box has to have the paths that the user needs.
     

Share This Page