aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-10-14 16:13:01 -0500
committerRob Landley <rob@landley.net>2019-10-14 16:13:01 -0500
commitae572524341c427b1f551ea4074a8c1d3d808681 (patch)
tree5161a1ce550366ac6cf196fc1cf2b6eac55b54de /toys
parenta4314f2da0cd501593083c29b02777bd9ac3f3b5 (diff)
downloadtoybox-ae572524341c427b1f551ea4074a8c1d3d808681.tar.gz
Make cmp work with 1 argument (implicit - as second argument).
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/cmp.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/toys/posix/cmp.c b/toys/posix/cmp.c
index c573f02e..d1c73f1d 100644
--- a/toys/posix/cmp.c
+++ b/toys/posix/cmp.c
@@ -4,15 +4,15 @@
*
* See http://opengroup.org/onlinepubs/9699919799/utilities/cmp.html
-USE_CMP(NEWTOY(cmp, "<2>2ls(silent)(quiet)[!ls]", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_ARGFAIL(2)))
+USE_CMP(NEWTOY(cmp, "<1>2ls(silent)(quiet)[!ls]", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_ARGFAIL(2)))
config CMP
bool "cmp"
default y
help
- usage: cmp [-l] [-s] FILE1 FILE2
+ usage: cmp [-l] [-s] FILE1 [FILE2 [SKIP1 [SKIP2]]]
- Compare the contents of two files.
+ Compare the contents of two files. (Or stdin and file if only one given.)
-l Show all differing bytes
-s Silent
@@ -80,4 +80,5 @@ void cmp_main(void)
toys.exitval = 2;
loopfiles_rw(toys.optargs, O_CLOEXEC|(WARN_ONLY*!(toys.optflags&FLAG_s)), 0,
do_cmp);
+ if (toys.optc == 1) do_cmp(0, "-");
}