From: Harald Hoyer Date: Mon, 23 Apr 2012 09:28:59 +0000 (+0200) Subject: base: add export_n() function X-Git-Tag: 019~91 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=476eb1b345764a7317f32da52b9b36f26fdf51ba;p=thirdparty%2Fdracut.git base: add export_n() function resembles export -n for dash --- diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index f46c4a748..a4aa20c30 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -821,3 +821,16 @@ emergency_shell() exit 1 fi } + +# Retain the values of these variables but ensure that they are unexported +# This is a POSIX-compliant equivalent of bash's "export -n" +export_n() +{ + local var + local val + for var in "$@"; do + eval val=\$$var + unset $var + [ -n "$val" ] && eval $var=\"$val\" + done +} diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh index cb0313730..aea739f98 100755 --- a/modules.d/99base/init.sh +++ b/modules.d/99base/init.sh @@ -251,7 +251,6 @@ done emergency_shell } - if [ $UDEVVERSION -lt 168 ]; then # stop udev queue before killing it udevadm control --stop-exec-queue @@ -268,13 +267,10 @@ 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 +debug_off # Turn off debugging for this section + +# unexport some vars +export_n root rflags fstype netroot NEWROOT export RD_TIMESTAMP # Clean up the environment