base: add export_n() function

resembles export -n for dash
master
Harald Hoyer 2012-04-23 11:28:59 +02:00
parent c32908cee3
commit 476eb1b345
2 changed files with 17 additions and 8 deletions

View File

@ -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
}

View File

@ -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