浏览代码

zsh_reload: use $SHELL to reload zsh only if it's a zsh shell (fixes #9054)

Marc Cornellà 3 年之前
父节点
当前提交
cfb86cd08d
共有 1 个文件被更改,包括 12 次插入2 次删除
  1. 12 2
      plugins/zsh_reload/zsh_reload.plugin.zsh

+ 12 - 2
plugins/zsh_reload/zsh_reload.plugin.zsh

@@ -7,6 +7,16 @@ src() {
 		zrecompile -p $f && command rm -f $f.zwc.old
 	done
 
-	# Use $SHELL if available; remove leading dash if login shell
-	[[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh
+	# Use $SHELL if it's available and a zsh shell
+	local shell="$ZSH_ARGZERO"
+	if [[ "${${SHELL:t}#-}" = zsh ]]; then
+		shell="$SHELL"
+	fi
+
+	# Remove leading dash if login shell and run accordingly
+	if [[ "${shell:0:1}" = "-" ]]; then
+		exec -l "${shell#-}"
+	else
+		exec "$shell"
+	fi
 }