klibc-bot for Herbert Xu
2020-Mar-28 21:48 UTC
[klibc] [klibc:update-dash] dash: builtin: Fix echo -n early termination
Commit-ID: 58ad7304f64a22cb58cdf6f45582e7f9d30aa89d Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=58ad7304f64a22cb58cdf6f45582e7f9d30aa89d 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: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: builtin: Fix echo -n early termination [ dash commit 4cf38c1ccd0c41715633c1b724c30e9c235099d1 ] 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';
Reasonably Related Threads
- [klibc:update-dash] builtin: Fix echo -n early termination
- [klibc:update-dash] dash: [BUILTIN] Simplify echo command
- [klibc:update-dash] dash: builtin: Move echo space/nl handling into print_escape_str
- [klibc:update-dash] builtin: Move echo space/nl handling into print_escape_str
- [klibc:update-dash] [BUILTIN] Simplify echo command