]> 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>
Fri, 3 Jul 2015 12:08:07 +0000 (14:08 +0200)
If "dinfo" is an executable, dracut-logger.sh would never be sourced.

See: https://bugzilla.redhat.com/show_bug.cgi?id=1167082
(cherry picked from commit 26d14fb3d36d6091f64258a62c49939478405693)

dracut-functions.sh

index 31586ca43ad3f473fa53975de3ee020d6f1da1ab..973e23125c285d2c39432d94d0e223b7d5a99c15 100755 (executable)
@@ -169,7 +169,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
@@ -202,12 +208,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() {