]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut-functions.sh: check if dinfo is a function
authorHarald Hoyer <harald@redhat.com>
Mon, 24 Nov 2014 14:17:45 +0000 (15:17 +0100)
committerHarald Hoyer <harald@redhat.com>
Mon, 24 Nov 2014 14:17:45 +0000 (15:17 +0100)
If "dinfo" is an executable, dracut-logger.sh would never be sourced.

See: https://bugzilla.redhat.com/show_bug.cgi?id=1167082

dracut-functions.sh

index b43b766470f982756fb8fe715af2141cbaa92c6d..17a71f0eb11c7834b9139768f6c1f5124ebaf592 100755 (executable)
@@ -176,7 +176,13 @@ srcmods="/lib/modules/$kernel/"
 }
 export srcmods
 
-if ! type dinfo >/dev/null 2>&1; then
+# is_func <command>
+# Check whether $1 is a function.
+is_func() {
+    [[ "$(type -t "$1")" = "function" ]]
+}
+
+if ! is_func dinfo >/dev/null 2>&1; then
     . "$dracutbasedir/dracut-logger.sh"
     dlog_init
 fi
@@ -209,12 +215,6 @@ mksubdirs() {
     [[ -e ${1%/*} ]] || mkdir -m 0755 -p -- "${1%/*}"
 }
 
-# is_func <command>
-# Check whether $1 is a function.
-is_func() {
-    [[ "$(type -t "$1")" = "function" ]]
-}
-
 # Function prints global variables in format name=value line by line.
 # $@ = list of global variables' name
 print_vars() {