#! /bin/sh # # Author: Mike Fleming mike@tauzero.co.uk # # Show source of a script that's found on the PATH # # Usage: # showit [ -v ] scriptname # # Options # -v Use fv to view file VIEWER=more VCASE=-i FTYPE="" USAGE="showit [-v] scriptname\n\n \t-v\tUse fv to view file\n" while getopts v opt do case $opt in v) VIEWER=fv VCASE="" FTYPE=sh;; ?) echo "Unknown option $OPTARG" echo "$USAGE" return 1;; *) echo "$USAGE" return 1;; esac done shift $((OPTIND - 1)) type $1 | read w1 w2 w3 if [[ "$w2" == "is" && "$w3" != "a shell builtin." ]] then $VIEWER $VCASE $w3 $FTYPE else echo $w1 $w2 $w3 fi