mkinitrd unification across distributions
 help / color / mirror / Atom feed
* [PATCH] Avoid use of "export -n"
@ 2012-03-16 21:11 Daniel Drake
       [not found] ` <20120316211124.8FFC69D401E-k/4jFdqg8LLlyo9zxV8I99HuzzzSOjJt@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Drake @ 2012-03-16 21:11 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

"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 |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
index 5d51c9d..f599fae 100755
--- a/modules.d/99base/init.sh
+++ b/modules.d/99base/init.sh
@@ -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
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-21 12:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-16 21:11 [PATCH] Avoid use of "export -n" Daniel Drake
     [not found] ` <20120316211124.8FFC69D401E-k/4jFdqg8LLlyo9zxV8I99HuzzzSOjJt@public.gmane.org>
2012-03-21 12:07   ` Harald Hoyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox