From 4497e4e3b119e188c7567a38ee8e401f2834a7c6 Mon Sep 17 00:00:00 2001 From: nirenjan Date: Wed, 9 Sep 2020 07:50:13 -0700 Subject: [PATCH] Use command -v to check for presence of a command With a fresh install of zsh on OSX Catalina, the which command returns text in stdout even if there is no corresponding command. Replacing it with `command -v` ensures that the test does not give a false positive. --- zsh/lscolors.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zsh/lscolors.zsh b/zsh/lscolors.zsh index c2ee65f..1e8f22a 100644 --- a/zsh/lscolors.zsh +++ b/zsh/lscolors.zsh @@ -44,10 +44,10 @@ DCFILE="$HOME/.dircolors" # a system which has the GNU coreutils installed if [[ -f $DCFILE ]] && [[ -s $DCFILE ]] then - if [[ ! -z `which dircolors` ]] + if command -v dircolors >/dev/null then eval `dircolors $DCFILE` - elif [[ ! -z `which gdircolors` ]] + elif command -v gdircolors >/dev/null then # OS X with coreutils installed from MacPorts will have # dircolors installed by default as gdircolors.