d988ee01c2450261225f5f5140ff51ea2c3325bf

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Merge pull request #4568 from blueyed/archlinux-improve-commands-lookup

archlinux: use $+commands instead of 'command -v' in a subshell

Diff

 1diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh
 2index b83c24560bf84c65629b90b7f0f5790ab966270f..99de5b936b11983d9f692e305187569edaaafb71 100644
 3--- a/plugins/archlinux/archlinux.plugin.zsh
 4+++ b/plugins/archlinux/archlinux.plugin.zsh
 5@@ -2,7 +2,7 @@
 6 # Usage is also described at https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins
 7 
 8 # Look for yaourt, and add some useful functions if we have it.
 9-if [[ -x `command -v yaourt` ]]; then
10+if (( $+commands[yaourt] )); then
11   upgrade () {
12     yaourt -Syu
13   }
14@@ -21,11 +21,11 @@ if [[ -x `command -v yaourt` ]]; then
15   alias yalst='yaourt -Qe'         # List installed packages, even those installed from AUR (they're tagged as "local")
16   alias yaorph='yaourt -Qtd'       # Remove orphans using yaourt
17   # Additional yaourt alias examples
18-  if [[ -x `command -v abs` && -x `command -v aur` ]]; then
19+  if (( $+commands[abs] && $+commands[aur] )); then
20     alias yaupd='yaourt -Sy && sudo abs && sudo aur'  # Update and refresh the local package, ABS and AUR databases against repositories
21-  elif [[ -x `command -v abs` ]]; then
22+  elif (( $+commands[abs] )); then
23     alias yaupd='yaourt -Sy && sudo abs'   # Update and refresh the local package and ABS databases against repositories
24-  elif [[ -x `command -v aur` ]]; then
25+  elif (( $+commands[aur] )); then
26     alias yaupd='yaourt -Sy && sudo aur'   # Update and refresh the local package and AUR databases against repositories
27   else
28     alias yaupd='yaourt -Sy'               # Update and refresh the local package database against repositories
29@@ -49,11 +49,11 @@ alias pacreps='pacman -Ss'             # Search for package(s) in the repositori
30 alias pacloc='pacman -Qi'              # Display information about a given package in the local database
31 alias paclocs='pacman -Qs'             # Search for package(s) in the local database
32 # Additional pacman alias examples
33-if [[ -x `command -v abs` && -x `command -v aur` ]]; then
34+if (( $+commands[abs] && $+commands[aur] )); then
35   alias pacupd='sudo pacman -Sy && sudo abs && sudo aur'  # Update and refresh the local package, ABS and AUR databases against repositories
36-elif [[ -x `command -v abs` ]]; then
37+elif (( $+commands[abs] )); then
38   alias pacupd='sudo pacman -Sy && sudo abs'              # Update and refresh the local package and ABS databases against repositories
39-elif [[ -x `command -v aur` ]]; then
40+elif (( $+commands[aur] )); then
41   alias pacupd='sudo pacman -Sy && sudo aur'              # Update and refresh the local package and AUR databases against repositories
42 else
43   alias pacupd='sudo pacman -Sy'     # Update and refresh the local package database against repositories