Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: linux
Compiler: gcc -I/usr/src/packages/BUILD/bash-2.05b 
-L/usr/src/packages/BUILD/bash-2.05b/../readline-4.3
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i586' 
-DCONF_OSTYPE='linux' -DCONF_MACHTYPE='i586-suse-linux' -DCONF_VENDOR='suse' 
-DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib  -O2 -march=i586 
-mcpu=i686 -fmessage-length=0 -Wall -D_GNU_SOURCE -Wall -pipe -g 
-fbranch-probabilities
uname output: Linux biker 2.6.5-7.201-default #1 Thu Aug 25 06:20:45 UTC 2005 
i686 i686 i386 GNU/Linux
Machine Type: i586-suse-linux

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:
The printf builtin doesn't correctly handle errors generating from writing to
stdout, e.g. if the stdout file descriptor is closed. No error condition is
returned, and the fd error status isn't reset.


Repeat-By:
The following script demonstrates the problem:

printf x >&-
PRINTF_STAT=$?
echo
ECHO_STAT=$?
echo "printf: $PRINTF_STAT (should be 1), echo: $ECHO_STAT (should be 0)"

Fix:
The following patch adds echo's stdout error handling to printf. 
Patch was tested successfully.

--- bash-2.05b/builtins/printf.def.orig 2002-05-13 20:36:04.000000000 +0200
+++ bash-2.05b/builtins/printf.def      2006-07-05 10:32:16.618545838 +0200
@@ -96,6 +96,11 @@ #define PRETURN(value) \
          conv_buf = 0; \
        } \
       fflush (stdout); \
+      if (ferror (stdout)) \
+        { \
+          clearerr (stdout); \
+          return (EXECUTION_FAILURE); \
+        } \
       return (value); \
     } \
   while (0)


_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to