diff --git a/.bashrc b/.bashrc
index c931ffb6bb2f1a05a58725f8dd2cd6a4e30415fd..b9cbac38e62452a834f6f85cf16508c7bda6d392 100644
--- a/.bashrc
+++ b/.bashrc
@@ -7,7 +7,7 @@ export HISTCONTROL=ignoreboth:erasedups
 export HISTSIZE=100000
 export HISTFILESIZE=100000
 export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
-if [ -n "$BASH" ]
+if [ -n "${BASH:-}" ]
 then
     shopt -s histappend
     shopt -s checkwinsize
@@ -26,7 +26,7 @@ fi
 [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
 
 # set variable identifying the chroot you work in (used in the prompt below)
-if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
+if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
     debian_chroot=$(cat /etc/debian_chroot)
 fi
 
diff --git a/.githooks/post-merge b/.githooks/post-merge
index 75d4c2094585f65a309edf7317efc93baf93bf0f..eca11391b4b5929847643b4fb9dacf5b0945d169 100755
--- a/.githooks/post-merge
+++ b/.githooks/post-merge
@@ -1,4 +1,5 @@
 #!/bin/sh
 set -eu
-. .bashrc
+cd "$(git rev-parse --show-toplevel)"
+. ./.bashrc
 gen-ssh-config