aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-03-02 08:33:01 -0600
committerRob Landley <rob@landley.net>2012-03-02 08:33:01 -0600
commit03a8f7430ebe694602646873371fdf067b735eb9 (patch)
treec658a675a3fada718b2a3862e125c6bee850be27
parent7339560d3f8581e988cfb7095918bf47b6e8f067 (diff)
downloadtoybox-03a8f7430ebe694602646873371fdf067b735eb9.tar.gz
Only show one normal difference (sans -l) and EOF message should go to stdout, not stderr.
-rw-r--r--toys/cmp.c7
1 files changed, 4 insertions, 3 deletions
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);
}