From f9425978e19a6b57640553f0a1ef43f1642ca970 Mon Sep 17 00:00:00 2001
From: Daniel Baumann <mail@daniel-baumann.ch>
Date: Thu, 24 Aug 2017 17:12:37 +0200
Subject: [PATCH 003/142] scripts: Use >&2 instead of /dev/stderr

/dev/stderr isn't always available in chroots, so use
>&2 instead.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=581649
https://bugs.freedesktop.org/show_bug.cgi?id=102388
---
 scripts/plymouth-populate-initrd.in   | 10 +++++-----
 scripts/plymouth-set-default-theme.in | 34 +++++++++++++++++-----------------
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/scripts/plymouth-populate-initrd.in b/scripts/plymouth-populate-initrd.in
index e3326e9..d0ffc23 100755
--- a/scripts/plymouth-populate-initrd.in
+++ b/scripts/plymouth-populate-initrd.in
@@ -337,10 +337,10 @@ inst_any() {
 }
 
 function usage() {
-    local output="/dev/stdout"
+    local output="/proc/self/fd/1"
     local rc=0
     if [ "$1" == "error" ]; then
-        output="/dev/stderr"
+        output="/proc/self/fd/2"
         rc=1
     fi
 
@@ -385,13 +385,13 @@ inst ${PLYMOUTH_POLICYDIR}/plymouthd.defaults $INITRDDIR
 inst ${PLYMOUTH_CONFDIR}/plymouthd.conf $INITRDDIR
 
 if [ -z "$PLYMOUTH_THEME_NAME" ]; then
-    echo "No default plymouth plugin is set" > /dev/stderr
+    echo "No default plymouth plugin is set" >&2
     exit 1
 fi
 
 if [ $THEME_OVERRIDE ]; then
     conf=$INITRDDIR/${PLYMOUTH_CONFDIR}/plymouthd.conf
-    echo "modifying plymouthd.conf: Theme=$PLYMOUTH_THEME_NAME" > /dev/stderr
+    echo "modifying plymouthd.conf: Theme=$PLYMOUTH_THEME_NAME" >&2
     # make sure the section and key exist so we can modify them
     grep -q "^ *\[Daemon\]" $conf || echo "[Daemon]" >> $conf
     grep -q "^ *Theme *=" $conf || echo "Theme=fade-in" >> $conf
@@ -401,7 +401,7 @@ fi
 PLYMOUTH_MODULE_NAME=$(grep "ModuleName *= *" ${PLYMOUTH_DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME}/${PLYMOUTH_THEME_NAME}.plymouth | sed 's/ModuleName *= *//')
 
 if [ ! -f ${PLYMOUTH_PLUGIN_PATH}/${PLYMOUTH_MODULE_NAME}.so ]; then
-    echo "The default plymouth plugin (${PLYMOUTH_MODULE_NAME}) doesn't exist" > /dev/stderr
+    echo "The default plymouth plugin (${PLYMOUTH_MODULE_NAME}) doesn't exist" >&2
     exit 1
 fi
 
diff --git a/scripts/plymouth-set-default-theme.in b/scripts/plymouth-set-default-theme.in
index 68e63d1..ed999e9 100755
--- a/scripts/plymouth-set-default-theme.in
+++ b/scripts/plymouth-set-default-theme.in
@@ -84,14 +84,14 @@ while [ $# -gt 0 ]; do
 
         -l|--list)
                 if [ -n "$THEME_NAME" ]; then
-                        echo "You can only specify --list or a theme name, not both" > /dev/stderr
-                        echo $(usage) > /dev/stderr
+                        echo "You can only specify --list or a theme name, not both" >&2
+                        echo $(usage) >&2
                         exit 1
                 fi
 
                 if [ $DO_RESET -ne 0 ]; then
-                        echo "You can only specify --reset or --list, not both" > /dev/stderr
-                        echo $(usage) > /dev/stderr
+                        echo "You can only specify --reset or --list, not both" >&2
+                        echo $(usage) >&2
                         exit 1
                 fi
 
@@ -104,14 +104,14 @@ while [ $# -gt 0 ]; do
 
         -r|--reset|default)
                 if [ -n "$THEME_NAME" ]; then
-                        echo "You can only specify --reset or a theme name, not both" > /dev/stderr
-                        echo $(usage) > /dev/stderr
+                        echo "You can only specify --reset or a theme name, not both" >&2
+                        echo $(usage) >&2
                         exit 1
                 fi
 
                 if [ $DO_LIST -ne 0 ]; then
-                        echo "You can only specify --reset or --list, not both" > /dev/stderr
-                        echo $(usage) > /dev/stderr
+                        echo "You can only specify --reset or --list, not both" >&2
+                        echo $(usage) >&2
                         exit 1
                 fi
 
@@ -124,20 +124,20 @@ while [ $# -gt 0 ]; do
 
         *)
                 if [ -n "$THEME_NAME" ]; then
-                        echo "You can only specify one theme at a time" > /dev/stderr
-                        echo $(usage) > /dev/stderr
+                        echo "You can only specify one theme at a time" >&2
+                        echo $(usage) >&2
                         exit 1
                 fi
 
                 if [ $DO_RESET -ne 0 ]; then
-                        echo "You can only specify --reset or a theme name, not both" > /dev/stderr
-                        echo $(usage) > /dev/stderr
+                        echo "You can only specify --reset or a theme name, not both" >&2
+                        echo $(usage) >&2
                         exit 1
                 fi
 
                 if [ $DO_LIST -ne 0 ]; then
-                        echo "You can only specify --list or a theme name, not both" > /dev/stderr
-                        echo $(usage) > /dev/stderr
+                        echo "You can only specify --list or a theme name, not both" >&2
+                        echo $(usage) >&2
                         exit 1
                 fi
 
@@ -163,7 +163,7 @@ if [ $DO_RESET -eq 0 ] && [ $DO_INITRD_REBUILD -eq 0 ] && [ -z $THEME_NAME ]; th
 fi
 
 if [ `id -u` -ne 0 ]; then
-        echo "This program must be run as root" > /dev/stderr
+        echo "This program must be run as root" >&2
         exit 1
 fi
 
@@ -174,14 +174,14 @@ if [ $DO_RESET -ne 0 ]; then
 fi
 
 if [ ! -e ${PLYMOUTH_DATADIR}/plymouth/themes/${THEME_NAME}/${THEME_NAME}.plymouth ]; then
-        echo "${PLYMOUTH_DATADIR}/plymouth/themes/${THEME_NAME}/${THEME_NAME}.plymouth does not exist" > /dev/stderr
+        echo "${PLYMOUTH_DATADIR}/plymouth/themes/${THEME_NAME}/${THEME_NAME}.plymouth does not exist" >&2
         exit 1
 fi
 
 MODULE_NAME=$(grep "ModuleName *= *" ${PLYMOUTH_DATADIR}/plymouth/themes/${THEME_NAME}/${THEME_NAME}.plymouth | sed 's/ModuleName *= *//')
 
 if [ ! -e ${PLYMOUTH_PLUGIN_PATH}${MODULE_NAME}.so ]; then
-        echo "${PLYMOUTH_PLUGIN_PATH}${MODULE_NAME}.so does not exist" > /dev/stderr
+        echo "${PLYMOUTH_PLUGIN_PATH}${MODULE_NAME}.so does not exist" >&2
         exit 1
 fi
 
-- 
2.7.4

