From 67e3a3758949c35f395284cb1cea41c4e17c3e95 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 29 Mar 2010 02:43:19 +0200 Subject: [PATCH] lib.sh: Don't require perl in installed(), instead use awk. --- lib.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib.sh b/lib.sh index 1fa3c8f..1862444 100644 --- a/lib.sh +++ b/lib.sh @@ -11,7 +11,11 @@ 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() { - which $1 2>&1 | perl -e '$_ = <>; if (not m{^/}) { exit 1 }' + # 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 }' } # Print the current OS. The following OS are supported at the moment: -- 2.43.2