git: b93791f5e7b0 - main - uniq: Correctly document the -D option.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 09 Dec 2024 19:45:19 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=b93791f5e7b0246b121dd98c10d6563298d6b2b0
commit b93791f5e7b0246b121dd98c10d6563298d6b2b0
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-12-09 19:44:34 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-12-09 19:44:34 +0000
uniq: Correctly document the -D option.
The -D option takes an optional argument; modify the usage message
and the manual page's synopsis to correctly reflect this. Also
update the tests to exercise -D with and without an argument.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D47999
---
usr.bin/uniq/tests/uniq_test.sh | 13 +++++++++++++
usr.bin/uniq/uniq.1 | 6 +++---
usr.bin/uniq/uniq.c | 4 ++--
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/usr.bin/uniq/tests/uniq_test.sh b/usr.bin/uniq/tests/uniq_test.sh
index 9d37245dee4e..fa37c1959a77 100755
--- a/usr.bin/uniq/tests/uniq_test.sh
+++ b/usr.bin/uniq/tests/uniq_test.sh
@@ -53,7 +53,12 @@ count_repeated_head() {
count_repeated_body() {
printf "a\na\nb\nb\na\n" >input
printf " 2 a\n 2 b\n" >expected
+ atf_check_uniq -cd
+ atf_check_uniq -c -d
+ atf_check_uniq -dc
+ atf_check_uniq -d -c
atf_check_uniq --count --repeated
+ atf_check_uniq --repeated --count
}
atf_test_case all_repeated
@@ -64,7 +69,15 @@ all_repeated_body() {
printf "a\na\nb\na\na\n" >input
printf "a\na\na\na\n" >expected
atf_check_uniq -D
+ atf_check_uniq -Dnone
atf_check_uniq --all-repeated
+ atf_check_uniq --all-repeated=none
+ printf "\na\na\n\na\na\n" >expected
+ atf_check_uniq -Dprepend
+ atf_check_uniq --all-repeated=prepend
+ printf "a\na\n\na\na\n" >expected
+ atf_check_uniq -Dseparate
+ atf_check_uniq --all-repeated=separate
}
atf_test_case skip_fields
diff --git a/usr.bin/uniq/uniq.1 b/usr.bin/uniq/uniq.1
index 30dee856d772..0918420e2229 100644
--- a/usr.bin/uniq/uniq.1
+++ b/usr.bin/uniq/uniq.1
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 12, 2024
+.Dd December 9, 2024
.Dt UNIQ 1
.Os
.Sh NAME
@@ -36,8 +36,8 @@
.Nd report or filter out repeated lines in a file
.Sh SYNOPSIS
.Nm
-.Op Fl c | Fl d | Fl D | Fl u
-.Op Fl i
+.Op Fl cdiu
+.Op Fl D Ns Op Ar septype
.Op Fl f Ar num
.Op Fl s Ar chars
.Oo
diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c
index 9978c4996dc7..1c022e633cf3 100644
--- a/usr.bin/uniq/uniq.c
+++ b/usr.bin/uniq/uniq.c
@@ -366,7 +366,7 @@ obsolete(char *argv[])
static void
usage(void)
{
- (void)fprintf(stderr,
-"usage: uniq [-c | -d | -D | -u] [-i] [-f fields] [-s chars] [input [output]]\n");
+ (void)fprintf(stderr, "usage: uniq [-cdiu] [-D[septype]] "
+ "[-f fields] [-s chars] [input [output]]\n");
exit(1);
}