diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2016-09-02 21:14:39 +0800 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2020-03-28 21:42:54 +0000 |
commit | 58ad7304f64a22cb58cdf6f45582e7f9d30aa89d (patch) | |
tree | 2f019f088fda1faf8b39ca946fc61118bea41bbb | |
parent | 5d0e205c474c4df839f92663457acc991d867c25 (diff) | |
download | klibc-58ad7304f64a22cb58cdf6f45582e7f9d30aa89d.tar.gz |
[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@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | usr/dash/bltin/printf.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/usr/dash/bltin/printf.c b/usr/dash/bltin/printf.c index 78bf388a99376..9da4ffef2e4f2 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'; |