Index | Thread | Search

From:
obsd@mulh.net
Subject:
Re: cal: add option to highlight the current day
To:
tech@openbsd.org
Date:
Wed, 19 Aug 2026 18:38:24 -0400

Download raw body.

Thread
  • obsd@mulh.net:

    cal: add option to highlight the current day

Ok my LAST post on this (I can hear your cheers).

I'm only posting this because my previous version has
a glaring bug you would notice come October 1st.
It's not a quoting issue but sed doesn't like
(.{0}) and complains about empty expression (picky).
This only happened after my month/year merge.
Ok added a stopgap to fix the empty expression.

Also discovered my linux co-test host has three
spaces between months instead of bsd's two spaces.
Fine, update my width offset to work on both and
verify many combinations still work as expected.
I just can't think of a dynamic way (in sed) to
accurately determine month boundaries on a line
of numbers.

So for the archives and anyone not using ncal.

cal -y | eval sed -r "\"$(date '+/%Y/,$ s/^/~/;/  %Y/,$ s/~(.{0,$((2%m%%3*22))}())/\1~/;
	/%B/,/[^ ]{4}/s/(~.{0,20})(%e)\>/\1`tput so`\2`tput se`/;s/~//')\""

Was a good brain exercise but time to move on
to the next puzzle.

A good reminder why OpenBSD does so much regression
testing after any src change, no matter how small.