From ae572524341c427b1f551ea4074a8c1d3d808681 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 14 Oct 2019 16:13:01 -0500 Subject: Make cmp work with 1 argument (implicit - as second argument). --- toys/posix/cmp.c | 7 ++++--- 1 file 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, "-"); } -- cgit v1.2.3