From 03a8f7430ebe694602646873371fdf067b735eb9 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 2 Mar 2012 08:33:01 -0600 Subject: Only show one normal difference (sans -l) and EOF message should go to stdout, not stderr. --- toys/cmp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'toys') diff --git a/toys/cmp.c b/toys/cmp.c index 471952b2..87fbe024 100644 --- a/toys/cmp.c +++ b/toys/cmp.c @@ -63,17 +63,17 @@ void do_cmp(int fd, char *name) if (!(toys.optflags & FLAG_s)) { printf("%s %s differ: char %ld, line %ld\n", TT.name, name, byte_no, line_no); + toys.exitval++; } - return; + goto out; } - } byte_no++; if (toybuf[i] == '\n') line_no++; } if (len1 != len2) { if (!(toys.optflags & FLAG_s)) { - fdprintf(2, "cmp: EOF on %s\n", + printf("cmp: EOF on %s\n", len1 < len2 ? TT.name : name); } toys.exitval = 1; @@ -81,6 +81,7 @@ void do_cmp(int fd, char *name) } if (len1 < 1) break; } +out: if (CFG_TOYBOX_FREE) close(TT.fd); } -- cgit v1.2.3