+usage() {
+ printf "Usage: $0 <program> [<arguments>]
+
+Available options:
+
+ -h | --help display this usage information
+ -p <program> check specified argument instead of default args, like:
+ $(basename $0) -p aumix xterm -T aumix -e aumix
+"
+}
+
+is_installed() {
+ prog="$1"
+ [ -z "$prog" ] && return 1
+
+ case "${prog}" in
+ /*) # deal with absolute-path programs
+ [ -x "${prog}" ] && return 0
+ return 1 ;;
+ esac
+
+ ret=1
+ oifs="$IFS"
+ IFS=:
+ for dir in $PATH; do
+ [ -z "$dir" ] && continue
+ [ -x "$dir/$prog" ] && ret=0 && break
+ done
+
+ IFS="$oifs"
+ unset oifs
+ return "$ret"
+}
+