Michael Prokop <bts@bts.grml.org>:
> Michael Prokop <mika@grml.org> added the comment:
[snip]
#!/bin/bash
Seems like a plain sh script to me.
Bash can handle that of course. But it's not needed, AFAICS.
# use Xdisplay only if present and running under X:
display_info() {
if type -a Xdialog 1>/dev/null 2>&1 && test -n "$DISPLAY" ; then
Xdialog --title "grml-exec-wrapper" --msgbox "$1" 0 0 0
else
print "$1">&2
stderr? really?
fi
}
if [ -z "$1" ] ; then
display_info "Usage: $0 <program> [<arguments>]"
exit 1
fi
RC='0'
PROG="$1"
# make sure to support 'grml-exec-wrapper sudo wireshark' as well:
case $PROG in
*sudo*) PROG="$2" ;;
esac
if type -a "$PROG" 1>/dev/null 2>&1 ; then
exec $@
Rather:
exec "$@"
else
RC=1
display_info "Sorry: ${PROG} not available.
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}
"
fi
The whole RC variable is unneeded.
The only way, you end up down here is if you come down from the else
path above (which is unneeded, for the very same reason.
Just 'exit 1' should be good enough (and much clearer).
If you're wondering why: if you call exec, the shell is done. It's
gone and won't come back.
exit $RC
[snap]
Regards, Frank |