(nitpick) When invoked with a single argument and this argument is not a number, cal(1) thinks it is a month name and calls parsemonth() on it.
If this non-numeric argument is not a valid month name, it exit with the following error message: > invalid month: use 1-12 or a name That error message is OK when invoking cal(1) like this > cal le_month 2023 "le_month" is indeed an invalid month name. However, invoking cal(1) like this: > cal le_month warns the same error message: > invalid month: use 1-12 or a name A 1-12 number there is interpreted as a year number, not as a month. The errx(3) call in parsemonth() is not necessary, for its return value is already checked when parsemonth() is called. I then removed the call to errx(3) and just returned 0, which is checked against by the caller. Index: usr.bin/cal/cal.c =================================================================== RCS file: /cvs/src/usr.bin/cal/cal.c,v retrieving revision 1.30 diff -u -p -r1.30 cal.c --- usr.bin/cal/cal.c 9 Oct 2015 01:37:06 -0000 1.30 +++ usr.bin/cal/cal.c 24 Jan 2023 04:16:42 -0000 @@ -196,7 +196,7 @@ main(int argc, char *argv[]) case 2: month = parsemonth(*argv++); if (!month) - errx(1, "Unable to parse month"); + errx(1, "invalid month: use 1-12 or a name"); /* FALLTHROUGH */ case 1: if (argc == 1 && !isdigit((unsigned char)*argv[0])) { @@ -559,6 +559,6 @@ parsemonth(const char *s) v = tm.tm_mon + 1; } if (v <= 0 || v > 12) - errx(1, "invalid month: use 1-12 or a name"); + return 0; return (v); }