X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_bin%2Fgrml-exec-wrapper;h=5466d024e0a625c54b13961b3a48296334aafa12;hb=dcb6090b9e23b455fb7b043c340508e3373e6a40;hp=f20ffd4aeb549636064019901f0056e9fc66832a;hpb=7760a197c555cc8fa6e72653dca0a53b0e950dff;p=grml-scripts.git diff --git a/usr_bin/grml-exec-wrapper b/usr_bin/grml-exec-wrapper index f20ffd4..5466d02 100755 --- a/usr_bin/grml-exec-wrapper +++ b/usr_bin/grml-exec-wrapper @@ -6,9 +6,26 @@ # License: This file is licensed under the GPL v2 or any later version. ################################################################################ +is_installed() { + prog="$1" + [ -z "$prog" ] && return 1 + + ret=1 + oifs="$IFS" + IFS=: + for dir in $PATH; do + [ -z "$dir" ] && continue + [ -x "$dir/$prog" ] && ret=0 && break + done + + IFS="$oifs" + unset oifs + return "$ret" +} + # use Xdisplay only if present and running under X: display_info() { -if type -a Xdialog 1>/dev/null 2>&1 && test -n "$DISPLAY" ; then +if is_installed Xdialog && test -n "$DISPLAY" ; then Xdialog --title "grml-exec-wrapper" --msgbox "$1" 0 0 0 else print "$1">&2 @@ -20,7 +37,6 @@ if [ -z "$1" ] ; then exit 1 fi -RC='0' PROG="$1" # make sure to support 'grml-exec-wrapper sudo wireshark' as well: @@ -28,28 +44,11 @@ case $PROG in *sudo*) PROG="$2" ;; esac -is_installed() { - prog="$1" - [ -z "$prog" ] && return 1 - - ret=1 - oifs="$IFS" - IFS=: - for dir in $PATH; do - [ -z "$dir" ] && continue - [ -x "$dir/$prog" ] && ret=0 && break - done - - IFS="$oifs" - unset oifs - return "$ret" -} +if is_installed "$PROG" ; then + exec "$@" +fi -if is_installed "$PROG" 1>/dev/null 2>&1 ; then - exec $@ -else - RC=1 - display_info "Sorry: ${PROG} not available. +display_info "Sorry: ${PROG} not available. Looks like the grml flavour you are using does not ship ${PROG}. :( @@ -57,8 +56,7 @@ You can search for ${PROG} executing: apt-get update && apt-cache search ${PROG} " -fi -exit $RC +exit 1 ## END OF FILE #################################################################