Re: cal: add option to highlight the current day

[email protected]
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.