|
Harald Hoyer |
2f4f1d |
From 476eb1b345764a7317f32da52b9b36f26fdf51ba Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
2f4f1d |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
2f4f1d |
Date: Mon, 23 Apr 2012 11:28:59 +0200
|
|
Harald Hoyer |
2f4f1d |
Subject: [PATCH] base: add export_n() function
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
resembles export -n for dash
|
|
Harald Hoyer |
2f4f1d |
---
|
|
Harald Hoyer |
2f4f1d |
modules.d/99base/dracut-lib.sh | 13 +++++++++++++
|
|
Harald Hoyer |
2f4f1d |
modules.d/99base/init.sh | 12 ++++--------
|
|
Harald Hoyer |
2f4f1d |
2 files changed, 17 insertions(+), 8 deletions(-)
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
|
|
Harald Hoyer |
2f4f1d |
index f46c4a7..a4aa20c 100755
|
|
Harald Hoyer |
2f4f1d |
--- a/modules.d/99base/dracut-lib.sh
|
|
Harald Hoyer |
2f4f1d |
+++ b/modules.d/99base/dracut-lib.sh
|
|
Harald Hoyer |
2f4f1d |
@@ -821,3 +821,16 @@ emergency_shell()
|
|
Harald Hoyer |
2f4f1d |
exit 1
|
|
Harald Hoyer |
2f4f1d |
fi
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
+
|
|
Harald Hoyer |
2f4f1d |
+# Retain the values of these variables but ensure that they are unexported
|
|
Harald Hoyer |
2f4f1d |
+# This is a POSIX-compliant equivalent of bash's "export -n"
|
|
Harald Hoyer |
2f4f1d |
+export_n()
|
|
Harald Hoyer |
2f4f1d |
+{
|
|
Harald Hoyer |
2f4f1d |
+ local var
|
|
Harald Hoyer |
2f4f1d |
+ local val
|
|
Harald Hoyer |
2f4f1d |
+ for var in "$@"; do
|
|
Harald Hoyer |
2f4f1d |
+ eval val=\$$var
|
|
Harald Hoyer |
2f4f1d |
+ unset $var
|
|
Harald Hoyer |
2f4f1d |
+ [ -n "$val" ] && eval $var=\"$val\"
|
|
Harald Hoyer |
2f4f1d |
+ done
|
|
Harald Hoyer |
2f4f1d |
+}
|
|
Harald Hoyer |
2f4f1d |
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
|
|
Harald Hoyer |
2f4f1d |
index cb03137..aea739f 100755
|
|
Harald Hoyer |
2f4f1d |
--- a/modules.d/99base/init.sh
|
|
Harald Hoyer |
2f4f1d |
+++ b/modules.d/99base/init.sh
|
|
Harald Hoyer |
2f4f1d |
@@ -251,7 +251,6 @@ done
|
|
Harald Hoyer |
2f4f1d |
emergency_shell
|
|
Harald Hoyer |
2f4f1d |
}
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
-
|
|
Harald Hoyer |
2f4f1d |
if [ $UDEVVERSION -lt 168 ]; then
|
|
Harald Hoyer |
2f4f1d |
# stop udev queue before killing it
|
|
Harald Hoyer |
2f4f1d |
udevadm control --stop-exec-queue
|
|
Harald Hoyer |
2f4f1d |
@@ -268,13 +267,10 @@ else
|
|
Harald Hoyer |
2f4f1d |
udevadm info --cleanup-db
|
|
Harald Hoyer |
2f4f1d |
fi
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
-# Retain the values of these variables but ensure that they are unexported
|
|
Harald Hoyer |
2f4f1d |
-# This is a POSIX-compliant equivalent of bash's "export -n"
|
|
Harald Hoyer |
2f4f1d |
-for var in root rflags fstype netroot NEWROOT; do
|
|
Harald Hoyer |
2f4f1d |
- eval tmp=\$$var
|
|
Harald Hoyer |
2f4f1d |
- unset $var
|
|
Harald Hoyer |
2f4f1d |
- [ -n "$tmp" ] && eval $var=\"$tmp\"
|
|
Harald Hoyer |
2f4f1d |
-done
|
|
Harald Hoyer |
2f4f1d |
+debug_off # Turn off debugging for this section
|
|
Harald Hoyer |
2f4f1d |
+
|
|
Harald Hoyer |
2f4f1d |
+# unexport some vars
|
|
Harald Hoyer |
2f4f1d |
+export_n root rflags fstype netroot NEWROOT
|
|
Harald Hoyer |
2f4f1d |
|
|
Harald Hoyer |
2f4f1d |
export RD_TIMESTAMP
|
|
Harald Hoyer |
2f4f1d |
# Clean up the environment
|