projects
/
grml-scripts.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7760a19
)
Move is_installed to the very beginning
author
Michael Prokop
<mika@grml.org>
Sun, 15 Feb 2009 15:52:50 +0000
(16:52 +0100)
committer
Michael Prokop
<mika@grml.org>
Sun, 15 Feb 2009 15:52:50 +0000
(16:52 +0100)
usr_bin/grml-exec-wrapper
patch
|
blob
|
history
diff --git
a/usr_bin/grml-exec-wrapper
b/usr_bin/grml-exec-wrapper
index
f20ffd4
..
ed97b86
100755
(executable)
--- 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.
################################################################################
# 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() {
# 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 1>/dev/null 2>&1 && test -n "$DISPLAY" ; then
Xdialog --title "grml-exec-wrapper" --msgbox "$1" 0 0 0
else
print "$1">&2
Xdialog --title "grml-exec-wrapper" --msgbox "$1" 0 0 0
else
print "$1">&2
@@
-28,23
+45,6
@@
case $PROG in
*sudo*) PROG="$2" ;;
esac
*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" 1>/dev/null 2>&1 ; then
exec $@
else
if is_installed "$PROG" 1>/dev/null 2>&1 ; then
exec $@
else