f7d4f985ac391e4532a5e6331e0c296fad4a913c

Author
Hong <hong@topbug.net>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Use $+commands to check the existence of a command in clipboard.zsh. (#5519)

Diff

 1diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh
 2index b663800a4d09bb9918d5f33d3188c81d58ea8882..2c93d1bb5c3a2af2cca739b96e46c6dbb38d6dd3 100644
 3--- a/lib/clipboard.zsh
 4+++ b/lib/clipboard.zsh
 5@@ -31,13 +31,13 @@ function clipcopy() {
 6       cat $file > /dev/clipboard
 7     fi
 8   else
 9-    if which xclip &>/dev/null; then
10+    if (( $+commands[xclip] )); then
11       if [[ -z $file ]]; then
12         xclip -in -selection clipboard
13       else
14         xclip -in -selection clipboard $file
15       fi
16-    elif which xsel &>/dev/null; then
17+    elif (( $+commands[xsel] )); then
18       if [[ -z $file ]]; then
19         xsel --clipboard --input 
20       else
21@@ -74,9 +74,9 @@ function clippaste() {
22   elif [[ $OSTYPE == cygwin* ]]; then
23     cat /dev/clipboard
24   else
25-    if which xclip &>/dev/null; then
26+    if (( $+commands[xclip] )); then
27       xclip -out -selection clipboard
28-    elif which xsel &>/dev/null; then
29+    elif (( $+commands[xsel] )); then
30       xsel --clipboard --output
31     else
32       print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2