From 2d685482afbb89570f0b62b0e0a6006228fe5d27 Mon Sep 17 00:00:00 2001 From: sin Date: Fri, 21 Nov 2014 12:03:27 +0000 Subject: [PATCH] Update cmp(1) manpage to new style and do not allow both -l and -s to be set --- cmp.1 | 59 +++++++++++++++++++++++++++++++++++------------------------ cmp.c | 4 ++-- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/cmp.1 b/cmp.1 index 02b5631..dc345d9 100644 --- a/cmp.1 +++ b/cmp.1 @@ -1,25 +1,36 @@ -.TH CMP 1 sbase\-VERSION -.SH NAME -cmp \- compare two files -.SH SYNOPSIS -.B cmp -.RB [ \-ls ] -.RI file1 -.RI file2 -.SH DESCRIPTION -.B cmp -compares two files byte by byte. If the files differ, cmp prints the byte and +.Dd November 21, 2014 +.Dt CMP 1 sbase\-VERSION +.Os +.Sh NAME +.Nm cmp +.Nd compare two files +.Sh SYNOPSIS +.Nm cmp +.Op Fl l | Fl s +.Ar file1 file2 +.Sh DESCRIPTION +.Nm +compares two files byte by byte. If the files differ, +.Nm +prints the byte and line number at which the difference occurred. -.P -The status code is 0 if the files are identical, and 1 if not. If an error -occurred the status code is 2. -.SH OPTIONS -.TP -.B \-l -prints the byte number, and the differing bytes (in octal), for each difference. -.TP -.B \-s -prints nothing, only returns status. -.SH SEE ALSO -.IR comm (1), -.IR diff (1) +.Pp +.Sh OPTIONS +.Bl -tag -width Ds +.It Fl l +Prints the byte number, and the differing bytes (in octal), for each difference. +.It Fl s +Prints nothing, only returns status. +.El +.Sh EXIT STATUS +.Bl -tag -width Ds +.It 0 +The files are identical. +.It 1 +The files are different. +.It >1 +An error occured. +.El +.Sh SEE ALSO +.Xr comm 1 , +.Xr diff 1 diff --git a/cmp.c b/cmp.c index 976bc00..a11538e 100644 --- a/cmp.c +++ b/cmp.c @@ -10,7 +10,7 @@ enum { Same = 0, Diff = 1, Error = 2 }; static void usage(void) { - enprintf(Error, "usage: %s [-ls] file1 file2\n", argv0); + enprintf(Error, "usage: %s [-l | -s] file1 file2\n", argv0); } int @@ -34,7 +34,7 @@ main(int argc, char *argv[]) usage(); } ARGEND; - if (argc != 2) + if (argc != 2 || (lflag && sflag)) usage(); if (argv[0][0] == '-' && !argv[0][1])