News for hackers. Stuff that matters.
Re:Show HN: A fix for the .bash_profile .bashrc .profile mad... by jasomill on Sunday August 12, 2012 @12:24AM (#4371832)
Alternatively, just ensure sourcing .bash_profile is idempotent[1], then .bashrc can simply be

    if [ -n "$PS1" -a -r "$HOME/.bash_profile" ]; then
        . "$HOME/.bash_profile"
    fi
because, on all platforms, PS1 is non-empty on startup iff bash is interactive.

[1] E.g., assuming PATH starts out non-empty, this

    export PATH_DEFAULT PATH="<stuff>:${PATH_DEFAULT:=$PATH}:<other stuff>"
should work for PATH in bash much as

    if [ -z "$PATH_DEFAULT" ]; then
        export PATH_DEFAULT="$PATH"
    fi
    export PATH="<stuff>:$PATH_DEFAULT:<other stuff>"
works in most any Bourne-derived shell. Having the _DEFAULT variables around comes in handy for clean build environments, as well (e.g., I build Emacs.app once and distribute it to several Macs, so I don't want configure to pull in random dependencies that just happen to be installed in MacPorts on my build machine).

There are no comments on this comment yet.