From: Harald Hoyer Date: Mon, 10 Aug 2015 11:40:43 +0000 (+0200) Subject: base/dracut-lib.sh: Dup stdout and stderr X-Git-Tag: 044~122 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6a2555c7ddde2ed542b2aae01d78a5c9309bf80;p=thirdparty%2Fdracut.git base/dracut-lib.sh: Dup stdout and stderr Dup stdout and stderr, so that subshell redirection does not affect logging. Also gets rid of systemd printing info() to the console on "quiet". --- diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index 5ec7b2347..200c26345 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -51,29 +51,45 @@ str_ends() { [ "${1%*"$2"}" != "$1" ] } +# Dup stdout and stderr, so that subshell redirection does not affect logging. +if [ -z "$DRACUT_STDOUT" ]; then + if [ -n "$BASH" ]; then + readonly DRACUT_STDOUT=98 + readonly DRACUT_STDERR=98 + exec 98>&1 + exec 99>&2 + else + readonly DRACUT_STDOUT=8 + readonly DRACUT_STDERR=9 + exec 8>&1 + exec 9>&2 + fi +fi + + if [ -z "$DRACUT_SYSTEMD" ]; then warn() { check_quiet echo "<28>dracut Warning: $*" > /dev/kmsg - echo "dracut Warning: $*" >&2 + echo "dracut Warning: $*" >&$DRACUT_STDERR } info() { check_quiet echo "<30>dracut: $*" > /dev/kmsg [ "$DRACUT_QUIET" != "yes" ] && \ - echo "dracut: $*" >&2 + echo "dracut: $*" >&$DRACUT_STDERR } else warn() { - echo "Warning: $*" >&2 + echo "Warning: $*" >&$DRACUT_STDERR } info() { - echo "$*" >&2 + echo "$*" >&$DRACUT_STDOUT } fi