diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2021-09-23 05:46:30 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2021-10-03 05:19:57 +0000 |
commit | e6eed7d7bc806c26e52eb0fe6c1c7f7f23eb3ea6 (patch) | |
tree | bdd8e6f5e7cb48ce445ba69389bde2c0c29af5fd /usr.bin/cmp/cmp.c | |
parent | b0f46c4b84093b23e8d40ffbc1f7f63659a0123c (diff) | |
download | src-e6eed7d7bc806c26e52eb0fe6c1c7f7f23eb3ea6.tar.gz src-e6eed7d7bc806c26e52eb0fe6c1c7f7f23eb3ea6.zip |
cmp: add -b, --print-bytes
This is compatible with GNU cmp.
Reviewed by: bapt, markj (earlier version)
Sponsored by: Klara, Inc.
(cherry picked from commit f66b9b40f403f7c30fec3c4ceed93c6e8fafa8ac)
Diffstat (limited to 'usr.bin/cmp/cmp.c')
-rw-r--r-- | usr.bin/cmp/cmp.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c index 256cef8a0c31..98ae96c73375 100644 --- a/usr.bin/cmp/cmp.c +++ b/usr.bin/cmp/cmp.c @@ -62,10 +62,11 @@ __FBSDID("$FreeBSD$"); #include "extern.h" -bool lflag, sflag, xflag, zflag; +bool bflag, lflag, sflag, xflag, zflag; static const struct option long_opts[] = { + {"print-bytes", no_argument, NULL, 'b'}, {"ignore-initial", required_argument, NULL, 'i'}, {"verbose", no_argument, NULL, 'l'}, {"bytes", required_argument, NULL, 'n'}, @@ -106,8 +107,11 @@ main(int argc, char *argv[]) skip1 = skip2 = 0; oflag = O_RDONLY; - while ((ch = getopt_long(argc, argv, "+hi:ln:sxz", long_opts, NULL)) != -1) + while ((ch = getopt_long(argc, argv, "+bhi:ln:sxz", long_opts, NULL)) != -1) switch (ch) { + case 'b': /* Print bytes */ + bflag = true; + break; case 'h': /* Don't follow symlinks */ oflag |= O_NOFOLLOW; break; |