From edd92d935d28111c140ce78d28ad3171a9a9bfc7 Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Thu, 22 Oct 2020 10:55:23 +0800 Subject: [PATCH] Use `command -v` to reduce zsh startup time --- z.lua.plugin.zsh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/z.lua.plugin.zsh b/z.lua.plugin.zsh index ce74e34..b929459 100644 --- a/z.lua.plugin.zsh +++ b/z.lua.plugin.zsh @@ -6,15 +6,11 @@ ZLUA_SCRIPT="${0:A:h}/z.lua" # search lua executable if [[ -z "$ZLUA_EXEC" ]]; then - if [[ -x "$(command which lua)" ]]; then - ZLUA_EXEC="$(command which lua)" - elif [[ -x "$(command which lua5.3)" ]]; then - ZLUA_EXEC="$(command which lua5.3)" - elif [[ -x "$(command which lua5.2)" ]]; then - ZLUA_EXEC="$(command which lua5.2)" - elif [[ -x "$(command which lua5.1)" ]]; then - ZLUA_EXEC="$(command which lua5.1)" - else + for lua in lua lua5.3 lua5.2 lua5.1; do + ZLUA_EXEC="$(command -v "$lua")" + [[ -n "$ZLUA_EXEC" ]] && break + done + if [[ -z "$ZLUA_EXEC" ]]; then echo "Not find lua in your $PATH, please install it." return fi