From f7d4f985ac391e4532a5e6331e0c296fad4a913c Mon Sep 17 00:00:00 2001 From: Hong Date: Mon, 10 Oct 2016 14:01:37 -0700 Subject: [PATCH] Use $+commands to check the existence of a command in clipboard.zsh. (#5519) --- lib/clipboard.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index b663800a..2c93d1bb 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -31,13 +31,13 @@ function clipcopy() { cat $file > /dev/clipboard fi else - if which xclip &>/dev/null; then + if (( $+commands[xclip] )); then if [[ -z $file ]]; then xclip -in -selection clipboard else xclip -in -selection clipboard $file fi - elif which xsel &>/dev/null; then + elif (( $+commands[xsel] )); then if [[ -z $file ]]; then xsel --clipboard --input else @@ -74,9 +74,9 @@ function clippaste() { elif [[ $OSTYPE == cygwin* ]]; then cat /dev/clipboard else - if which xclip &>/dev/null; then + if (( $+commands[xclip] )); then xclip -out -selection clipboard - elif which xsel &>/dev/null; then + elif (( $+commands[xsel] )); then xsel --clipboard --output else print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2