[klibc] [klibc:update-dash] builtin: Fix echo -n early termination
klibc-bot for Herbert Xu
herbert at gondor.apana.org.au
Thu Jan 24 19:15:44 PST 2019
Commit-ID: 2de7c2ab8c5b4706b634054407d634d7cd43a8ea
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=2de7c2ab8c5b4706b634054407d634d7cd43a8ea
Author: Herbert Xu <herbert at gondor.apana.org.au>
AuthorDate: Fri, 2 Sep 2016 21:14:39 +0800
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Fri, 25 Jan 2019 02:57:21 +0000
[klibc] 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 at gmail.com>
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
usr/dash/bltin/printf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/usr/dash/bltin/printf.c b/usr/dash/bltin/printf.c
index 78bf388a..9da4ffef 100644
--- a/usr/dash/bltin/printf.c
+++ b/usr/dash/bltin/printf.c
@@ -465,7 +465,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';
More information about the klibc
mailing list