Using "> /dev/fd/2" causes stderr to get truncated, which is mangles the log file if the user happens to have redirected it there.
Use ">&2" instead which redirects to the already open stderr and doesn't truncate it.
Reported-by: Tim Deegan tim@xen.org Tested-by: Tim Deegan tim@xen.org Signed-off-by: Ian Campbell ian.campbell@citrix.com
---
If this could go into the next stable release that would be very nice.
Thanks, Ian. --- tools/test-gcc.sh | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/tools/test-gcc.sh b/tools/test-gcc.sh index 935f211..05bae29 100755 --- a/tools/test-gcc.sh +++ b/tools/test-gcc.sh @@ -30,13 +30,13 @@ EOF $CC -O -g -c $TMPFILE1 -o $TMPFILE1o > /dev/null 2>&1 $LD -T $TMPFILE1_ld $TMPFILE1o -o $TMPFILE2o > /dev/null 2>&1 if [ $? -ne 0 ]; then - echo "The version of LD on this system does not properly handle" > /dev/fd/2 - echo "alignments. As a result, this project can not be built." > /dev/fd/2 - echo "" > /dev/fd/2 - echo "The problem may be the result of this LD bug report:" > /dev/fd/2 - echo " http://sourceware.org/bugzilla/show_bug.cgi?id=12726" > /dev/fd/2 - echo "" > /dev/fd/2 - echo "Please update to a working version of binutils and retry." > /dev/fd/2 + echo "The version of LD on this system does not properly handle" >&2 + echo "alignments. As a result, this project can not be built." >&2 + echo "" >&2 + echo "The problem may be the result of this LD bug report:" >&2 + echo " http://sourceware.org/bugzilla/show_bug.cgi?id=12726" >&2 + echo "" >&2 + echo "Please update to a working version of binutils and retry." >&2 echo -1 exit 0 fi @@ -45,7 +45,7 @@ fi # support the whole-program optimization - detect that. $CC -fwhole-program -S -o /dev/null -xc /dev/null > /dev/null 2>&1 if [ $? -ne 0 ]; then - echo " Working around no -fwhole-program" > /dev/fd/2 + echo " Working around no -fwhole-program" >&2 echo 2 exit 0 fi @@ -69,7 +69,7 @@ EOF $CC -Os -c -fwhole-program $TMPFILE2 -o $TMPFILE2o > /dev/null 2>&1 $CC -nostdlib -Os $TMPFILE1o $TMPFILE2o -o $TMPFILE3o > /dev/null 2>&1 if [ $? -ne 0 ]; then - echo " Working around non-functional -fwhole-program" > /dev/fd/2 + echo " Working around non-functional -fwhole-program" >&2 echo 2 exit 0 fi @@ -104,7 +104,7 @@ $CC -O -g -fwhole-program -combine -c $TMPFILE1 $TMPFILE2 -o $TMPFILE1o > /dev/n if [ $? -eq 0 ]; then echo 0 else - echo " Working around non-functional -combine" > /dev/fd/2 + echo " Working around non-functional -combine" >&2 echo 1 fi
On Thu, Mar 22, 2012 at 03:25:24PM +0000, Ian Campbell wrote:
Using "> /dev/fd/2" causes stderr to get truncated, which is mangles the log file if the user happens to have redirected it there.
Use ">&2" instead which redirects to the already open stderr and doesn't truncate it.
Thanks, I applied this change.
-Kevin