From: Thilo Six Date: Thu, 7 Nov 2013 08:50:31 +0000 (+0100) Subject: Rewrite check4progs from etc/grml/script-functions X-Git-Tag: v0.9.1~1 X-Git-Url: http://git.grml.org/?p=grml-etc-core.git;a=commitdiff_plain;h=3d5b16f470105b91bac350934155444aa13902e3 Rewrite check4progs from etc/grml/script-functions This largely simplifies the function and also fixes its behaviour when called with more than one argument. Signed-off-by: Frank Terbeck --- diff --git a/etc/grml/script-functions b/etc/grml/script-functions index a39e3d8..887cf2c 100644 --- a/etc/grml/script-functions +++ b/etc/grml/script-functions @@ -48,15 +48,25 @@ setdialog(){ # }}} # {{{ check for availability of program(s) -check4progs(){ - local RC='' - for arg in $* ; do - which $arg >/dev/null 2>&1 || RC="$arg" - done - if [ -n "$RC" ] ; then - echo "$RC not installed" - return 1 - fi +check4progs() { + local RTN=0 + local ARG='' + while [ ${#} -gt 0 ] + do + ARG="${1}" + shift + + # check for availability + if ! \which "${ARG}" >/dev/null 2>&1 + then + printf "%s: binary not found\n" "${ARG}" >&2 + RTN=1 + fi + + done + + # return non zero, if at least one prog is missing! + return ${RTN} } # }}}