Colorize freebsd-update diff output? (12.2)

Hi,

I'm planning an upgrade of some older systems. I have managed to implement nano syntax highligting for the interactive merges, but (how) can I add color to the non-interactive diff output? (when upgrading 12.2)

I'm talking about these ones:
Diff:
The following changes, which occurred between FreeBSD 12.4-RELEASE and
FreeBSD 13.2-RELEASE have been merged into /etc/group:
--- current version
+++ new version
@@ -1,6 +1,6 @@
-# $FreeBSD: releng/12.4/etc/group 359447 2020-03-30 17:07:05Z brooks $
+# $FreeBSD$
 #
 wheel:*:0:root
 daemon:*:1:
 kmem:*:2:
 sys:*:3:
@@ -16,10 +16,12 @@
 sshd:*:22:
 smmsp:*:25:
 mailnull:*:26:
 guest:*:31:
 video:*:44:
+realtime:*:47:
+idletime:*:48:
 bind:*:53:
 unbound:*:59:
 proxy:*:62:
 authpf:*:63:
 _pflogd:*:64:
I picked the diff syntax above to demonstrate exactly what I'm missing and hoping for.
 
/usr/sbin/freebsd-update is a shell script, so you can easily read what it does.

Code:
                        # Print changes for the user's approval.
                        cat <<-EOF

The following changes, which occurred between FreeBSD ${OLDRELNUM} and
FreeBSD ${RELNUM} have been merged into ${F}:
EOF
                        diff -U 5 -L "current version" -L "new version" \
                            merge/old/${F} merge/new/${F} || true
                        continuep < /dev/tty || return 1

It just shows the output from the diff(1) command.
 
Is this a diff(1) or a PAGER issue?

freebsd-update(8)
Code:
ENVIRONMENT
     PAGER  The pager program used to present various reports during the
            execution.  (Default: “/usr/bin/less”.)

When pager is set for example to sysutils/nvimpager, the output could be colorized as you wanted (assuming, not tried actually).

nvimpager.png


There might be other utilities colorizing the same I don't know of.
 
in 14.x diff --color=always but it does not work in 13.x and previous versions

or use git diff which has its own pager too
 
Yeah, I noticed the option was added later.

Thanks. I guess it is diff output. It's printed inline. Would it be foolish to edit the script to use git diff instead?

I might need to colorize paged output, too, I guess, so thanks for that, also!
 
I ended up modifying /usr/sbin/freebsd-update like so:

Diff:
-diff -U 5 -L "current version" -L "new version" \
+git diff --exit-code -U5 --src-prefix="current version/" --dst-prefix="    new version/" \

Seems to work.
 
Back
Top