From 4cf38c1ccd0c41715633c1b724c30e9c235099d1 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 2 Sep 2016 21:14:39 +0800 Subject: builtin: Fix echo -n early termination The commit 7a784244625d5489c0fc779201c349555dc5f8bc ("[BUILTIN] Simplify echo command") broke echo -n by making it always terminate after printing the first argument. This patch fixes this by only terminating when we have reached the end of the arguments. Fixes: 7a784244625d ("[BUILTIN] Simplify echo command") Reported-by: Luigi Tarenga Signed-off-by: Herbert Xu --- src/bltin/printf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bltin/printf.c b/src/bltin/printf.c index 1112253..a626cee 100644 --- a/src/bltin/printf.c +++ b/src/bltin/printf.c @@ -459,7 +459,7 @@ echocmd(int argc, char **argv) if (likely(*argv)) nonl += print_escape_str("%s", NULL, NULL, *argv++); - if (nonl > 0) + if (likely((nonl + !*argv) > 1)) break; c = *argv ? ' ' : '\n'; -- cgit 1.4.1