ambevar-dotfiles/.bin/bsdman

40 lines
752 B
Plaintext
Raw Normal View History

2013-11-14 13:19:14 +01:00
#!/bin/sh
2014-01-18 23:41:55 +01:00
if [ "${0##*/}" = "obsdman" ]; then
OS=OpenBSD
DOMAIN="http://www.openbsd.org/cgi-bin"
MANPATH="OpenBSD+Current"
2014-01-18 23:41:55 +01:00
else
OS=FreeBSD
DOMAIN="http://www.freebsd.org/cgi"
MANPATH="FreeBSD+10-current"
2014-01-18 23:41:55 +01:00
fi
usage () {
cat <<EOF>&2
2013-11-20 15:05:04 +01:00
Usage: ${0##*/} [SECTION] PAGE
2013-11-14 13:19:14 +01:00
2014-01-18 23:41:55 +01:00
Fetch $OS man page PAGE from the official website and display it.
2013-11-14 13:19:14 +01:00
EOF
}
[ $# -eq 0 ] && usage && exit 1
[ "$1" = "-h" ] && usage && exit
[ "$1" = "--" ] && shift
2013-11-14 13:19:14 +01:00
2013-11-20 15:05:04 +01:00
SECTION=0
PAGE=$1
if [ $# -eq 2 ]; then
SECTION="$1"
PAGE="$2"
2013-11-20 15:05:04 +01:00
fi
2016-10-10 14:01:09 +02:00
AGENT="curl -s -L"
if ! command -v curl >/dev/null 2>&1; then
AGENT="wget -q -O - "
2013-11-14 13:19:14 +01:00
fi
$AGENT "$DOMAIN/man.cgi?query=$PAGE&apropos=0&sektion=$SECTION&manpath=$MANPATH&arch=default&format=ascii" | if [ "$TERM" = dumb ]; then cat; else less; fi