#!/bin/bash set -u set -e ELINKS="$(/usr/bin/which elinks)" || true function usage { echo "Usage: $0 -f " } function lookup_function { local name="$1" local filename="function.$(echo "${name}" | /usr/bin/sed 's/_/-/g').html" if [ ! -n "${ELINKS}" ]; then echo "elinks not found." exit 1; fi elinks --no-references --no-numbering -dump -dump-color-mode 1 "/usr/share/doc/php/php-chunked-xhtml/${filename}" | less -R } opt_f= # Parse the arguments while getopts :f: opt ; do case ${opt} in f) opt_f="${OPTARG}" ;; \?) echo "Invalid option -${OPTARG}." exit 1 ;; :) echo "Missing parameter for -${OPTARG}." exit 1 ;; esac done if [ -n "${opt_f}" ]; then lookup_function "${opt_f}" else usage "$0" exit 1 fi