From d48ade736d265822c2332139930e24c83b32eede Mon Sep 17 00:00:00 2001 From: martijn Date: Fri, 13 Aug 2021 11:27:33 +0000 Subject: [PATCH] Make -b, -c, and -b mutually exclusive. Help/Feedback/OK schwarze@, tb@ --- usr.bin/jot/jot.1 | 16 +++++++++++++++- usr.bin/jot/jot.c | 8 +++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/usr.bin/jot/jot.1 b/usr.bin/jot/jot.1 index 4e11b900776..69c7c640409 100644 --- a/usr.bin/jot/jot.1 +++ b/usr.bin/jot/jot.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: jot.1,v 1.24 2021/08/13 07:59:04 martijn Exp $ +.\" $OpenBSD: jot.1,v 1.25 2021/08/13 11:27:33 martijn Exp $ .\" $NetBSD: jot.1,v 1.2 1994/11/14 20:27:36 jtc Exp $ .\" .\" Copyright (c) 1993 @@ -58,9 +58,18 @@ The options are as follows: Just print .Ar word repetitively. +Overrides earlier +.Fl b , +.Fl c , +and +.Fl w . .It Fl c This is an abbreviation for .Fl w Ic %c . +Overrides earlier +.Fl b +and +.Fl w . .It Fl n Do not print the final newline normally appended to the output. .It Fl p Ar precision @@ -99,6 +108,11 @@ are possible by using the appropriate conversion specification inside .Ar word , in which case the data is inserted rather than appended. +Overrides earlier +.Fl b , +.Fl c , +and +.Fl w . .El .Pp The last four arguments specify the length of the output sequence, diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c index e5d3f96bede..0051195bd9d 100644 --- a/usr.bin/jot/jot.c +++ b/usr.bin/jot/jot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: jot.c,v 1.54 2021/08/13 10:45:26 tb Exp $ */ +/* $OpenBSD: jot.c,v 1.55 2021/08/13 11:27:33 martijn Exp $ */ /* $NetBSD: jot.c,v 1.3 1994/12/02 20:29:43 pk Exp $ */ /*- @@ -70,6 +70,7 @@ static bool intdata; static bool longdata; static bool nosign; static bool randomize; +static bool word; static void getformat(void); static int getprec(char *); @@ -94,10 +95,13 @@ main(int argc, char *argv[]) switch (ch) { case 'b': boring = true; + chardata = word = false; format = optarg; break; case 'c': chardata = true; + boring = word = false; + format = ""; break; case 'n': finalnl = false; @@ -115,6 +119,8 @@ main(int argc, char *argv[]) sepstring = optarg; break; case 'w': + word = true; + boring = chardata = false; format = optarg; break; default: -- 2.20.1