From ce1f5a9cc34b3ca64f493cbdce22abc657eea362 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 29 Mar 2010 02:48:04 +0200 Subject: [PATCH] lib.sh: Use simpler version in installed() using cut. --- lib.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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: -- 2.45.2