From: Alejandro Colomar Date: Mon, 25 Nov 2024 11:36:08 +0000 (+0100) Subject: src/bin/diffman, diffman.1: Add program and its manual page X-Git-Tag: man-pages-6.10~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5ca29b20e0021040123c5d33b2f65f38d79b8e7;p=thirdparty%2Fman-pages.git src/bin/diffman, diffman.1: Add program and its manual page This program diffs manual pages. It's useful for reviewing changes to a manual page: $ diffman membarrier ./man2/membarrier.2 | less -R; Signed-off-by: Alejandro Colomar --- diff --git a/man/man1/diffman.1 b/man/man1/diffman.1 new file mode 100644 index 000000000..1c27f58d1 --- /dev/null +++ b/man/man1/diffman.1 @@ -0,0 +1,38 @@ +.\" Copyright 2024, Alejandro Colomar +.\" +.\" SPDX-License-Identifier: Linux-man-pages-copyleft +.\" +.TH diffman 1 (date) "Linux man-pages (unreleased)" +.SH NAME +diffman +\- +compare formatted manual pages line by line +.SH SYNOPSIS +.SY diffman +.I page1 +.I page2 +.YS +.SH DESCRIPTION +The +.B diffman +command +formats two manual pages, +and then runs +.BR diff (1) +on the formatted outputs. +.P +The pages are specified with the same syntax that +.BR man (1) +accepts. +.P +The output is suitable for piping to +.IR less\~\-R . +.SH EXAMPLES +.EX +.RB $\~ "diffman membarrier man2/membarrier.2 | less \-R" ; +$ +.EE +.SH SEE ALSO +.BR diff (1), +.BR man (1), +.BR less (1) diff --git a/src/bin/diffman b/src/bin/diffman new file mode 100755 index 000000000..56f674135 --- /dev/null +++ b/src/bin/diffman @@ -0,0 +1,35 @@ +#!/bin/bash +# +# Copyright 2024, Alejandro Colomar +# SPDX-License-Identifier: GPL-3.0-or-later + +set -Eeuo pipefail; +shopt -s lastpipe; + +err() +{ + >&2 echo "$(basename "$0"): error: $*"; + exit 1; +} + +if test $# -ne 2; then + err "Expected two arguments."; +fi; + +p1="$(man -w "$1")"; +p2="$(man -w "$2")"; + +printf '%s\n' "$1.XXXXXX" \ +| sed 's,.*/,,' \ +| xargs mktemp -t \ +| read -r t1; + +printf '%s\n' "$2.XXXXXX" \ +| sed 's,.*/,,' \ +| xargs mktemp -t \ +| read -r t2; + +groff -man -Tutf8 <"$p1" >"$t1"; +groff -man -Tutf8 <"$p2" >"$t2"; + +diff -u "$t1" "$t2";