summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2016-09-02 21:14:39 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2016-09-02 22:10:56 +0800
commit4cf38c1ccd0c41715633c1b724c30e9c235099d1 (patch)
tree7b0b4b40f59e2a644fe0a78d09050dc3b4157c21 /src
parentbuiltin: Fix handling of trailing IFS white spaces (diff)
downloaddash-4cf38c1ccd0c41715633c1b724c30e9c235099d1.tar.gz
dash-4cf38c1ccd0c41715633c1b724c30e9c235099d1.zip
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 <luigi.tarenga@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r--src/bltin/printf.c2
1 files changed, 1 insertions, 1 deletions
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';