projects
/
grml-scripts-core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
37bccb4
)
Add ist_installed(), thanks ft!
author
Michael Prokop
<mika@grml.org>
Sun, 15 Feb 2009 15:51:19 +0000
(16:51 +0100)
committer
Michael Prokop
<mika@grml.org>
Sun, 15 Feb 2009 15:51:19 +0000
(16:51 +0100)
usr_bin/grml-exec-wrapper
patch
|
blob
|
history
diff --git
a/usr_bin/grml-exec-wrapper
b/usr_bin/grml-exec-wrapper
index
a826be1
..
f20ffd4
100755
(executable)
--- a/
usr_bin/grml-exec-wrapper
+++ b/
usr_bin/grml-exec-wrapper
@@
-1,4
+1,4
@@
-#!/bin/
ba
sh
+#!/bin/sh
# Filename: grml-exec-wrapper
# Purpose: simple but smart program execution wrapper
# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# Filename: grml-exec-wrapper
# Purpose: simple but smart program execution wrapper
# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
@@
-28,7
+28,24
@@
case $PROG in
*sudo*) PROG="$2" ;;
esac
*sudo*) PROG="$2" ;;
esac
-if type -a "$PROG" 1>/dev/null 2>&1 ; then
+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
RC=1
exec $@
else
RC=1