X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_bin%2Fgrml-exec-wrapper;h=4e5a3ccbafe7b044c4ac42ef8017a101238192ed;hb=c6fa5b9b1a99cfd42fd9aa2c2ce465321f7845af;hp=6973b7053bda2d492a800c621950f69ff781d607;hpb=53d5cac317a6a56e1dfcf37344ed1e2484521f33;p=grml-scripts.git diff --git a/usr_bin/grml-exec-wrapper b/usr_bin/grml-exec-wrapper index 6973b70..4e5a3cc 100755 --- a/usr_bin/grml-exec-wrapper +++ b/usr_bin/grml-exec-wrapper @@ -6,21 +6,28 @@ # License: This file is licensed under the GPL v2 or any later version. ################################################################################ +PN=$(basename "$0") + usage() { - printf "Usage: $0 [] + printf "Usage: %s [] Available options: -h | --help display this usage information -p check specified argument instead of default args, like: - $(basename $0) -p aumix xterm -T aumix -e aumix -" + %s -p aumix xterm -T aumix -e aumix\n" "${PN}" "${PN}" } is_installed() { - prog="$(basename $1)" + prog="$1" [ -z "$prog" ] && return 1 + case "${prog}" in + /*) # deal with absolute-path programs + [ -x "${prog}" ] && return 0 + return 1 ;; + esac + ret=1 oifs="$IFS" IFS=: @@ -43,7 +50,7 @@ else fi } -if [ -z "$1" -o "$1" = '-h' -o "$1" = '--help' ] ; then +if [ -z "$1" ] || [ "$1" = '-h' ] || [ "$1" = '--help' ] ; then usage exit 1 fi @@ -51,10 +58,10 @@ fi if [ "$1" = '-p' ] ; then if [ -z "$2" ] ; then usage - exit 1 + exit 1 else PROG="$2" - shift ; shift + shift ; shift fi else PROG="$1" @@ -74,7 +81,7 @@ Looks like the grml flavour you are using does not ship ${PROG}. :( You can search for ${PROG} executing: -apt-get update && apt-cache search $(basename ${PROG}) +apt-get update && apt-cache search $(basename "${PROG}") " exit 1