File: diff_man_help.sh

package info (click to toggle)
svtplay-dl 4.97.1-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,104 kB
  • sloc: python: 8,626; makefile: 107; sh: 80
file content (57 lines) | stat: -rw-r--r-- 1,674 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# Make sure the options listed in --help and the manual are in sync.
TMPDIR=$(mktemp -d svtplay-man-test-XXXXXX)
[ "$TMPDIR" ] || {
	echo "mktemp not available, using static dir"
	TMPDIR=svtplay-man-test.tmp
	[ ! -e "$TMPDIR" ] || {
		echo "$TMPDIR already exists. Aborting."
		exit 1
	}
	mkdir "$TMPDIR"
}
trap 'rm -rf "$TMPDIR"' EXIT TERM

if echo "" | sed -r "" > /dev/null 2>&1 ; then
	extended_regexp="-r"
elif echo "" | sed -E "" > /dev/null 2>&1 ; then
	extended_regexp="-E"
else
	echo "Cant find extented regex"
fi

# FIXME: *Currently* we don't have any =head3 that doesn't
# document an option. This is thus fragile to changes.
sed $extended_regexp -ne 's/^=head3 //p' svtplay-dl.pod > $TMPDIR/options.man

./svtplay-dl --help |
	sed -ne 's/.*[, ]\(--[^,= ]\+\).*/\1/p' >$TMPDIR/options.help

# --help specific filtering
sed -i $extended_regexp -e 's/   .*//' $TMPDIR/options.help
sed -i $extended_regexp -e 's/  excl.*//' $TMPDIR/options.help
sed -i $extended_regexp -e 's/^ *//' $TMPDIR/options.help
sed -i $extended_regexp -e 's/OUTPUT/filename/g' $TMPDIR/options.help

# pod specific filtering
sed -n -i $extended_regexp -e 's/\(^ *(--[^,= ]+).*\)/\1/p' $TMPDIR/options.man

for file in $TMPDIR/options.*; do
	sed -i $extended_regexp -e 's/, / /' $file
	sed -i $extended_regexp -e 's/  / /' $file

	# Normalize order of --help -h vs -h --help
	#  "--help -h"   =>  "-h --help"
	perl -i -pe 's/^(-.(?: [^-][^ ]+)?) (--.*)/\2 \1/' $file
done

OS=$(uname -s)
SHA1="sha1sum"
[ "$OS" = "Darwin*" ] || {
	SHA1="shasum"
}

[ "$($SHA1<$TMPDIR/options.help)" = "$($SHA1<$TMPDIR/options.man)" ] || {
	diff -u $TMPDIR/options.help $TMPDIR/options.man
	exit 1
}