diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index 207e9c4a801a2b2ce3562b6934cc9d5fee827a53..c3d9ef260cd440e37270e937b913525d821f7f97 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -212,7 +212,8 @@ _spack_determine_shell() {
         # If procfs is present this seems a more reliable
         # way to detect the current shell
         _sp_exe=$(readlink /proc/$$/exe)
-        basename ${_sp_exe}
+        # Shell may contain number, like zsh5 instead of zsh
+        basename ${_sp_exe} | tr -d '0123456789'
     elif [ -n "${BASH:-}" ]; then
         echo bash
     elif [ -n "${ZSH_NAME:-}" ]; then