-
-
Save hacolab/577ae29e44a9ead71c2ec816c69eb8ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
CMD_NAME=`basename "$0"` | |
TMP_FILE="/tmp/${CMD_NAME}.$$.html" | |
Usage(){ | |
cat <<- HELPEND | |
$CMD_NAME [-v version] [section-number] page-name | |
-v target freebsd version | |
HELPEND | |
} | |
GetManVer(){ | |
cat <<- VEREND | grep "^$1" | head -n 1 | |
13.0.2 | |
12.1.2 | |
12.0.2 | |
11.3.2 | |
11.2.2 | |
11.1.2 | |
11.0.2 | |
10.5.2 | |
10.4.2 | |
10.3.2 | |
10.2.2 | |
10.1.2 | |
10.0.2 | |
9.4.2 | |
9.3.2 | |
9.2.2 | |
9.1.2 | |
9.0.2 | |
8.4.2 | |
VEREND | |
} | |
# analyze option & params | |
BASE_URL="http://www.koganemaru.co.jp/" | |
FIX_QUERY='cgi-bin/mroff.cgi?subdir=man&lc=1' | |
VERSION=12.0.2 | |
CMD= | |
OPT= | |
while getopts v: OPT | |
do | |
case $OPT in | |
v ) VERSION=`GetManVer "${OPTARG}"` | |
[ -z "$VERSION" ] && echo "Invalid target version '$OPTARG'" && exit 1 | |
;; | |
\?) Usage && exit 1 | |
;; | |
esac | |
done | |
shift `expr $OPTIND - 1` | |
if [ $# -eq 0 ]; then | |
w3m "$BASE_URL/search.html" | |
exit 1 | |
elif [ $# -eq 1 ]; then | |
SECTION=0 | |
PAGENAME=$1 | |
else | |
SECTION=$1 | |
PAGENAME=$2 | |
fi | |
# get man page | |
wget -k -q -O "$TMP_FILE" "${BASE_URL}${FIX_QUERY}&cmd=${CMD}&man=${PAGENAME}&dir=jpman-${VERSION}%2Fman§=${SECTION}" | |
sed '/<br><h1>/,/Table of Contents/d' < "$TMP_FILE" |\ | |
w3m -I EUC-JP -O UTF-8 -T "text/html" | |
# clear temp file | |
rm $TMP_FILE | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment