]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Avoid use of "export -n"
authorDaniel Drake <dsd@laptop.org>
Fri, 16 Mar 2012 21:11:24 +0000 (21:11 +0000)
committerHarald Hoyer <harald@redhat.com>
Wed, 21 Mar 2012 12:04:58 +0000 (13:04 +0100)
"export -n" is a bash extension, not part of POSIX, and is hence
incompatible with the busybox shell.

This was breaking boot when the busybox module was used.

Reimplement the scope change in a few lines of standard shell code.

modules.d/99base/init.sh

index fa712a749ef7245cbb9ae25433860539c987b204..84c13e037f14eb28f1c277c473327e2b87410565 100755 (executable)
@@ -263,8 +263,15 @@ else
     udevadm info --cleanup-db
 fi
 
+# Retain the values of these variables but ensure that they are unexported
+# This is a POSIX-compliant equivalent of bash's "export -n"
+for var in root rflags fstype netroot NEWROOT; do
+    eval tmp=\$$var
+    unset $var
+    [ -n "$tmp" ] && eval $var=\"$tmp\"
+done
+
 export RD_TIMESTAMP
-export -n root rflags fstype netroot NEWROOT
 set +x # Turn off debugging for this section
 # Clean up the environment
 for i in $(export -p); do