Skip to content
Permalink
Browse files

Merge pull request #82 from 4ndrej/patch-1

refactor checkUtils: remove repeating commands
  • Loading branch information...
arzzen committed Oct 27, 2019
2 parents 17fc8f3 + c8ad2fb commit dc72babb2030704908f30860cb3a9ad70a0ee10f
Showing with 7 additions and 15 deletions.
  1. +7 −15 git-quick-stats
@@ -35,21 +35,13 @@ _theme="${_MENU_THEME:=default}"
################################################################################
function checkUtils() {
local -r msg="not found. Please make sure this is installed and in PATH."

command -v awk >/dev/null 2>&1 || { echo >&2 "awk ${msg}"; exit 1; }
command -v basename >/dev/null 2>&1 || { echo >&2 "basename ${msg}"; exit 1; }
command -v cat >/dev/null 2>&1 || { echo >&2 "cat ${msg}"; exit 1; }
command -v column >/dev/null 2>&1 || { echo >&2 "column ${msg}"; exit 1; }
command -v echo >/dev/null 2>&1 || { echo >&2 "echo ${msg}"; exit 1; }
command -v git >/dev/null 2>&1 || { echo >&2 "git ${msg}"; exit 1; }
command -v grep >/dev/null 2>&1 || { echo >&2 "grep ${msg}"; exit 1; }
command -v head >/dev/null 2>&1 || { echo >&2 "head ${msg}"; exit 1; }
command -v seq >/dev/null 2>&1 || { echo >&2 "seq ${msg}"; exit 1; }
command -v sort >/dev/null 2>&1 || { echo >&2 "sort ${msg}"; exit 1; }
command -v tput >/dev/null 2>&1 || { echo >&2 "tput ${msg}"; exit 1; }
command -v tr >/dev/null 2>&1 || { echo >&2 "tr ${msg}"; exit 1; }
command -v uniq >/dev/null 2>&1 || { echo >&2 "uniq ${msg}"; exit 1; }
command -v wc >/dev/null 2>&1 || { echo >&2 "wc ${msg}"; exit 1; }
declare -ar utils=("awk" "basename" "cat" "column" "echo" "git" "grep" "head"
"seq" "sort" "tput" "tr" "uniq" "wc")

for u in "${utils[@]}"
do
command -v "$u" >/dev/null 2>&1 || { echo >&2 "$u ${msg}"; exit 1; }
done
}

################################################################################

0 comments on commit dc72bab

Please sign in to comment.
You can’t perform that action at this time.