Index | Thread | Search

From:
Johannes Thyssen Tishman <jtt@openbsd.org>
Subject:
Re: cal's -y flag usage
To:
tech@openbsd.org
Date:
Sat, 27 Jun 2026 08:58:54 +0000

Download raw body.

Thread
2026-06-26T16:34:57+0200 Jeremie Courreges-Anglas <jca@wxcvbn.org>:
> The error message isn't accurate.  I'd rather you use something like
> below.  ok jca@ if you like it.

Thanks, fine by me. Any objections?

Index: usr.bin/cal/cal.1
===================================================================
RCS file: /cvs/src/usr.bin/cal/cal.1,v
diff -u -p -r1.33 cal.1
--- usr.bin/cal/cal.1	31 Jul 2024 17:09:23 -0000	1.33
+++ usr.bin/cal/cal.1	27 Jun 2026 08:57:39 -0000
@@ -72,6 +72,10 @@ and
 are mutually exclusive.
 .It Fl y
 Display a calendar for the current year.
+This option is ignored if
+.Ar year
+is specified and conflicts with specifying a
+.Ar month .
 .El
 .Pp
 A single numerical parameter specifies the
Index: usr.bin/cal/cal.c
===================================================================
RCS file: /cvs/src/usr.bin/cal/cal.c,v
diff -u -p -r1.33 cal.c
--- usr.bin/cal/cal.c	26 Jun 2026 12:34:45 -0000	1.33
+++ usr.bin/cal/cal.c	27 Jun 2026 08:57:39 -0000
@@ -193,10 +193,14 @@ main(int argc, char *argv[])
 	month = 0;
 	switch(argc) {
 	case 2:
+		if (yflag)
+			errx(1, "specifying a month conflicts with -y");
 		month = parsemonth(*argv++);
 		/* FALLTHROUGH */
 	case 1:
 		if (argc == 1 && !isdigit((unsigned char)*argv[0])) {
+			if (yflag)
+				errx(1, "specifying a month conflicts with -y");
 			month = parsemonth(*argv);
 			(void)time(&now);
 			local_time = localtime(&now);