Index | Thread | Search

From:
landry@openbsd.org
Subject:
Re: cal: add option to highlight the current day
To:
Johannes Thyssen Tishman <jtt@openbsd.org>, tech@openbsd.org
Date:
Sat, 4 Jul 2026 10:57:06 +0200

Download raw body.

Thread
Le Fri, Jul 03, 2026 at 04:37:29PM +0000, Johannes Thyssen Tishman a écrit :
> Please find below a patch to add an option (-h) to cal to allow
> highlighting the current day.
> 
> For testing purposes, the -h flag takes an optional argument specifying
> the date to highlight, e.g., cal -h2026-10-10 oct. I intend to remove
> this before committing if the patch is accepted.
> 
> The highlight_day function was mostly taken from FreeBSD[1]. Their
> implementation falls back to underlining the date (IIUC) if the terminal
> has no standout mode. I decided to leave this out for now and simply
> ignore the -h flag in this case.
> 
> To test this and check for regressions, I used the attached script. The
> script tests the in-tree patched cal against the unpatched installed
> one. It probably doesn't cover all scenarios, but hopefully enough.  In
> fact, it is probably a little excessive, as it tests every day of 28
> years, hehe. There's probably a smarter way to do this.
> 
> Lastly, I'm not super confident in my C skills yet so please don't hold
> back on your feedback. I've added some comments with questions in parts
> I'm not so sure about. I'd be grateful for any input on these.

i wont be able to comment on the code itself but the feature works and
is much welcome.