Debian Codegraph @

sync-manpages-with-help-output.sh

raw symbols SCIP
1 #! /usr/bin/env bash
2 # Copyright (C) 2022 Sebastian Pipping <[email protected]>
3 # Licensed under GPL v3 or later
4
5 set -e
6 set -o pipefail
7
8 _BUILD_MONTH=2026-07 # for reproducible builds; bump when doing releases
9
10 sed_args=(
11 # Produce familiar section "synopsis"
12 -e 's,^\.SH DESCRIPTION,.SH SYNOPSIS,'
13 -e 's,^usage: ,,'
14 -e 's,.*\[\\-\\-yes\]$,\0\n.SH DESCRIPTION,'
15
16 # Repair usage line bugs
17 -e 's,\]\\fR,\\fR\\],' # un-colorize closing square bracket
18 -e 's,\[\(\\-\\-[a-z\\-]\+\),[\\fB\1\\fR,g' # colorize --argument in brackets
19
20 # Be robust towards version difference between local help2man and CI help2man
21 -e 's,It was generated by help2man .*,It was generated by help2man.,'
22
23 # Put epilog in its own section
24 -e 's,^Software libre.*,.SH EPILOG\n\0,'
25
26 # Format "git-delete-merged-branches" in bold everywhere after section "NAME"
27 -e 's,\(^\| \)\(git\\-\(delete\\-merged\\-branches\|dmb\)\) ,\n.B \2\n,g'
28
29 # Un-colorize --merged in "git branch --merged"
30 -e 's,git branch \\fB\\-\\-merged\\fR,git branch \\-\\-merged,'
31 )
32
33 for i in git-delete-merged-branches git-dmb ; do
34 SOURCE_DATE_EPOCH="$(date --date="${_BUILD_MONTH}-15" +%s)" \
35 NO_COLOR=please \
36 COLUMNS=400 \
37 help2man \
38 --locale='en_US.UTF-8' \
39 --no-info \
40 --name 'Command-line tool to delete merged Git branches' \
41 ${i} \
42 | sed "${sed_args[@]}" \
43 > ${i}.1
44 done