Skip to content
Snippets Groups Projects
Commit 7a784244 authored by Herbert Xu's avatar Herbert Xu
Browse files

[BUILTIN] Simplify echo command

parent a6849899
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -9,6 +9,7 @@
* Remove getintmax in printf.
* Use error instead of warnx for fatal errors in printf.
* Optimise handling of backslash octals in printf.
* Simplify echo command.
 
2014-10-13 Eric Blake <eblake@redhat.com>
 
Loading
Loading
Loading
Loading
@@ -442,33 +442,21 @@ check_conversion(const char *s, const char *ep)
int
echocmd(int argc, char **argv)
{
int nonl = 0;
struct output *outs = out1;
if (!*++argv)
goto end;
if (equal(*argv, "-n")) {
nonl = ~nonl;
if (!*++argv)
goto end;
}
int nonl;
nonl = *++argv ? equal(*argv, "-n") : 0;
argv += nonl;
 
do {
int c;
 
nonl += print_escape_str("%s", NULL, NULL, *argv);
if (likely(*argv))
nonl += print_escape_str("%s", NULL, NULL, *argv++);
if (nonl > 0)
break;
 
c = ' ';
if (!*++argv) {
end:
if (nonl) {
break;
}
c = '\n';
}
outc(c, outs);
c = *argv ? ' ' : '\n';
out1c(c);
} while (*argv);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment