Skip to content

Commit

Permalink
Only execute .bashrc if not a login shell
Browse files Browse the repository at this point in the history
Also, set a version in the builtin naverc, so that we can
safely make changes to it, and be sure that they'll be
overwritten when nave is updated.
  • Loading branch information
isaacs committed Feb 22, 2012
1 parent 233574d commit 81b3b04
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions nave.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,28 @@ main () {
fi

# set up the naverc init file.
if ! [ -f "$NAVE_DIR/naverc" ]; then
# Important! Update this number any time the init content is changed.
local rcversion="#2"
if ! [ -f "$NAVE_DIR/naverc" ] \
|| [ "$(head -n1 "$NAVE_DIR/naverc")" != "$rcversion" ]; then
cat > "$NAVE_DIR/naverc" <<RC
$rcversion
[ "\$NAVE_DEBUG" != "" ] && set -x || true
if [ "\$NAVE_LOGIN" != "" ]; then
[ -f ~/.bash_profile ] && . ~/.bash_profile || true
[ -f ~/.bash_login ] && . ~/.bash_login || true
[ -f ~/.profile ] && . ~/.profile || true
else
[ -f ~/.bashrc ] && . ~/.bashrc || true
fi
[ -f ~/.bashrc ] && . ~/.bashrc || true
export PATH=\$NAVEPATH:\$PATH
[ -f ~/.naverc ] && . ~/.naverc || true
RC
fi

# couldn't write file
if ! [ -f "$NAVE_DIR/naverc" ]; then
if ! [ -f "$NAVE_DIR/naverc" ] \
|| [ "$(head -n1 "$NAVE_DIR/naverc")" != "$rcversion" ]; then
fail "Nave dir $NAVE_DIR is not writable."
fi

Expand Down

0 comments on commit 81b3b04

Please sign in to comment.