From: Michael Prokop Date: Sat, 4 Apr 2009 17:50:32 +0000 (+0200) Subject: Support -p option in grml-exec-wrapper X-Git-Tag: v1.1.18~6^2 X-Git-Url: http://git.grml.org/?p=grml-scripts.git;a=commitdiff_plain;h=53d5cac317a6a56e1dfcf37344ed1e2484521f33 Support -p option in grml-exec-wrapper --- diff --git a/usr_bin/grml-exec-wrapper b/usr_bin/grml-exec-wrapper index 8159246..6973b70 100755 --- a/usr_bin/grml-exec-wrapper +++ b/usr_bin/grml-exec-wrapper @@ -6,8 +6,19 @@ # License: This file is licensed under the GPL v2 or any later version. ################################################################################ +usage() { + printf "Usage: $0 [] + +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 +" +} + is_installed() { - prog="$1" + prog="$(basename $1)" [ -z "$prog" ] && return 1 ret=1 @@ -25,24 +36,33 @@ is_installed() { # use Xdisplay only if present and running under X: display_info() { -if is_installed Xdialog && test -n "$DISPLAY" ; then - Xdialog --title "grml-exec-wrapper" --msgbox "$1" 0 0 0 +if is_installed xterm && test -n "$DISPLAY" ; then + xterm -T 'Sorry :(' -e "dialog --msgbox \"$1\" 0 0" else printf '%s\n' "$1">&2 fi } -if [ -z "$1" ] ; then - display_info "Usage: $0 []" +if [ -z "$1" -o "$1" = '-h' -o "$1" = '--help' ] ; then + usage exit 1 fi -PROG="$1" - -# make sure to support 'grml-exec-wrapper sudo wireshark' as well: -case $PROG in - *sudo*) PROG="$2" ;; -esac +if [ "$1" = '-p' ] ; then + if [ -z "$2" ] ; then + usage + exit 1 + else + PROG="$2" + shift ; shift + fi +else + PROG="$1" + # make sure to support 'grml-exec-wrapper sudo wireshark' as well: + case $PROG in + *sudo*) PROG="$2" ;; + esac +fi if is_installed "$PROG" ; then exec "$@" @@ -54,7 +74,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 ${PROG} +apt-get update && apt-cache search $(basename ${PROG}) " exit 1