-
Notifications
You must be signed in to change notification settings - Fork 10
/
man-online
executable file
·55 lines (44 loc) · 948 Bytes
/
man-online
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
#!/bin/bash -e
section=
helpandquit()
{
cat <<-EOF
Usage: $0 [man options] [[section] page ...] ...
OPTIONS:
-h, --help help screen
EOF
exit 0
}
cleanup()
{
[ -z "$tmpdir" ] || rm -rf "$tmpdir"
}
show()
{
local topic="${1:?}"
if ! curl -s -f -o "$tmpdir/$topic".gz -f -L https://manpages.opensuse.org/"$topic${section:+.}$section".gz; then
echo "Failed to fetch $topic" >&2
return 0
fi
mandoc -l "$tmpdir/$topic.gz"
}
getopttmp=$(getopt -o hs: --long help -n "${0##*/}" -- "$@")
eval set -- "$getopttmp"
while true ; do
case "$1" in
-h|--help) helpandquit ;;
-s) section="$2"; shift 2 ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
[ -z "$1" ] && helpandquit
tmpdir=$(mktemp -d -t addimageencryption.XXXXXX)
trap cleanup EXIT
if [ -z "$section" ] && [ "${1/#[0-9]/}" != "$1" ]; then
section="$1"
shift
fi
for i in "$@"; do
show "$i"
done