From: Simon Ruderich Date: Mon, 29 Mar 2010 00:48:04 +0000 (+0200) Subject: lib.sh: Use simpler version in installed() using cut. X-Git-Url: https://ruderich.org/simon/gitweb/?p=config%2Fdotfiles.git;a=commitdiff_plain;h=ce1f5a9cc34b3ca64f493cbdce22abc657eea362 lib.sh: Use simpler version in installed() using cut. --- diff --git a/lib.sh b/lib.sh index 1862444..045af4c 100644 --- a/lib.sh +++ b/lib.sh @@ -11,11 +11,7 @@ unset LS_COLORS # Check if the given program is installed. Returns 0 if it exists, 1 # otherwise; so it can be used in if. installed() { - # Thanks to Rado in #awk on Freenode (2010-03-29 01:34) for the END tip to - # also work with empty stdin, and to prince_jammys in #awk on Freenode - # (2010-03-29 02:20) for a shorter syntax for "$0 !~". - which $1 2>&1 | awk '{ if (!/^\//) exit 1 } - END { if (NR == 0) exit 1 }' + [ x`which $1 2>&1 | cut -c 1` = x/ ] || return 1 } # Print the current OS. The following OS are supported at the moment: