Message ID | 3efcd42c-e20b-3506-3d62-69b85c027ef4@gigawatt.nl (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Herbert Xu |
Headers | show |
diff --git a/src/bltin/printf.c b/src/bltin/printf.c index 9673e10..b7b6d68 100644 --- a/src/bltin/printf.c +++ b/src/bltin/printf.c @@ -447,16 +447,20 @@ echocmd(int argc, char **argv) nonl = *++argv ? equal(*argv, "-n") : 0; argv += nonl; - do { - int c; + if (*argv) { + for (;;) { + if (print_escape_str("%s", NULL, NULL, *argv)) + return 0; + + if (!*++argv) + break; + + out1c(' '); + } + } - if (likely(*argv)) - nonl += print_escape_str("%s", NULL, NULL, *argv++); - if (nonl > 0) - break; + if (!nonl) + out1c('\n'); - c = *argv ? ' ' : '\n'; - out1c(c); - } while (*argv); return 0; }