diff --git a/helpers/forall-git b/helpers/forall-git
index 611d53e7b201ab6d198ac34a394f11b3fa66b557..8ef165b19e2055c4c4ee919fe80bd26d336df584 100755
--- a/helpers/forall-git
+++ b/helpers/forall-git
@@ -15,10 +15,10 @@ else
 
   find -L . -maxdepth 3 -name .git -type d|while read gitdir; do
     projectdir=$(dirname $gitdir)
-    pushd $projectdir > /dev/null
-    WD=$(basename $(pwd))
+    pushd "$projectdir" > /dev/null || exit
+    WD=$(basename "$(pwd)")
     echo -e "${COLOR}${WD}${NC}"
     "$@"
-    popd > /dev/null
+    popd > /dev/null || exit
   done
 fi