aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2018-05-02 01:32:34 +0000
committerKyle Evans <kevans@FreeBSD.org>2018-05-02 01:32:34 +0000
commit8facfdcf2107b31c9430a223ea9b497a5377a666 (patch)
tree22ffcad320dca72dc55cfe580bc2cce946cc05d4
parenta597327b9040542182760547def3242062aec440 (diff)
downloadsrc-8facfdcf2107b31c9430a223ea9b497a5377a666.tar.gz
src-8facfdcf2107b31c9430a223ea9b497a5377a666.zip
cmp(1): Provide some long options
These match GNU cmp(1) for compatibility where applicable. Future work might implement the -i option from GNU cmp(1) to express skip either in terms of both files or of the form "SKIP1:SKIP2" rather than specifying them as additional arguments to cmp(1). MFC after: 1 month
Notes
Notes: svn path=/head/; revision=333157
-rw-r--r--usr.bin/cmp/cmp.16
-rw-r--r--usr.bin/cmp/cmp.c11
2 files changed, 13 insertions, 4 deletions
diff --git a/usr.bin/cmp/cmp.1 b/usr.bin/cmp/cmp.1
index 1264604bbde9..f3bfdf651b51 100644
--- a/usr.bin/cmp/cmp.1
+++ b/usr.bin/cmp/cmp.1
@@ -31,7 +31,7 @@
.\" @(#)cmp.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd November 18, 2013
+.Dd May 1, 2018
.Dt CMP 1
.Os
.Sh NAME
@@ -59,10 +59,10 @@ The following options are available:
.Bl -tag -width indent
.It Fl h
Do not follow symbolic links.
-.It Fl l
+.It Fl l , Fl -verbose
Print the byte number (decimal) and the differing
byte values (octal) for each difference.
-.It Fl s
+.It Fl s , Fl -silent , Fl -quiet
Print nothing for differing files; return exit
status only.
.It Fl x
diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c
index ea67a939d5b0..b47df0c8da7a 100644
--- a/usr.bin/cmp/cmp.c
+++ b/usr.bin/cmp/cmp.c
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <getopt.h>
#include <nl_types.h>
#include <stdio.h>
#include <stdlib.h>
@@ -62,6 +63,14 @@ __FBSDID("$FreeBSD$");
int lflag, sflag, xflag, zflag;
+static const struct option long_opts[] =
+{
+ {"verbose", no_argument, NULL, 'l'},
+ {"silent", no_argument, NULL, 's'},
+ {"quiet", no_argument, NULL, 's'},
+ {NULL, no_argument, NULL, 0}
+};
+
static void usage(void);
int
@@ -75,7 +84,7 @@ main(int argc, char *argv[])
uint32_t fcntls;
oflag = O_RDONLY;
- while ((ch = getopt(argc, argv, "hlsxz")) != -1)
+ while ((ch = getopt_long(argc, argv, "+hlsxz", long_opts, NULL)) != -1)
switch (ch) {
case 'h': /* Don't follow symlinks */
oflag |= O_NOFOLLOW;