[PATCH] printf: fix exit code for %c and %s
Colin Watson
cjwatson at ubuntu.com
Thu Jun 25 19:05:29 UTC 2009
print_direc needs to reset errno on entry, as some paths (those for %c
and %s) don't go through multiconvert and thus don't reset errno there.
This was showing up as a test suite failure:
FAIL: printf understands %s '"x' "'y" "'zTAIL"
(I discovered this because one of the core components of the
Debian/Ubuntu installer relies on printf in a 'set -e' script, and so
the installer ended up completely non-functional.)
Signed-off-by: Colin Watson <cjwatson at ubuntu.com>
---
coreutils/printf.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/coreutils/printf.c b/coreutils/printf.c
index 5b326c6..8836800 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -144,6 +144,8 @@ static void print_direc(char *format, unsigned fmt_length,
char saved;
char *have_prec, *have_width;
+ errno = 0;
+
saved = format[fmt_length];
format[fmt_length] = '\0';
--
1.6.3.1
More information about the busybox
mailing list