diff options
Diffstat (limited to 'ponysay')
-rwxr-xr-x | ponysay | 51 |
1 files changed, 47 insertions, 4 deletions
@@ -21,13 +21,29 @@ version() { scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2` listcmd="$0list.pl" +haspq=1 +if [[ -f './pq4ps-list' ]]; then + function qlist + { ./pq4ps-list + } +elif [[ -f '/usr/bin/pq4ps-list' ]]; then + function qlist + { /usr/bin/pq4ps-list + } +else + haspq=0 + function qlist + { cat + } +fi + list() { echo -e "\\e[01mponyfiles located in $SYSTEMPONIES:\\e[21m" - perl $listcmd $scrw $(ls --color=no $SYSTEMPONIES | sed -e 's/\.pony$//' | sort) + perl $listcmd $scrw $(ls --color=no $SYSTEMPONIES | sed -e 's/\.pony$//' | sort) | qlist if [[ -d $HOMEPONIES ]]; then echo -e "\\e[01mponyfiles located in $HOMEPONIES:\\e[21m" - perl $listcmd $scrw $(ls --color=no $HOMEPONIES | sed -e 's/\.pony$//' | sort) + perl $listcmd $scrw $(ls --color=no $HOMEPONIES | sed -e 's/\.pony$//' | sort) | qlist fi } @@ -116,7 +132,7 @@ while (\$i < \$argc) } EOF - perl $listcmd $scrw $(cat /dev/shm/ponysay~) | sed -e 's/_/ /g' + perl $listcmd $scrw $(cat /dev/shm/ponysay~) | sed -e 's/_/ /g' | qlist } linklist() { @@ -140,6 +156,13 @@ Options: -h Show this help and exit. -l List pony files. -L List pony files with synonyms inside brackets. +EOF +if [[ $haspq = 1 ]]; then + cat <<EOF + -q Use the pony quote feature. +EOF +fi +cat <<EOF -f[name] Select a pony (either a file name or a pony name.) -W[column] The screen column where the message should be wrapped. @@ -199,7 +222,12 @@ say() { ponies=() -while getopts f:W:Llhv OPT +opts="f:W:Llhv" +if [[ $haspq ]]; then + opts=$opts"q" +fi +usepq=0 +while getopts $opts OPT do case ${OPT} in v) version; exit ;; @@ -208,11 +236,26 @@ do l) list; exit ;; L) linklist; exit ;; W) wrap="$OPTARG" ;; + q) usepq=1 ;; \?) usage >&2; exit 1 ;; esac done shift $((OPTIND - 1)) +if [[ $usepq = 1 ]]; then + if [[ -f './pq4ps' ]]; then + function q + { ./pq4ps $@ + } + elif [[ -f '/usr/bin/pq4ps' ]]; then + function q + { /usr/bin/pq4ps $@ + } + fi + $0 ${wrap:+-W$wrap} $(q "$*") + exit +fi + hash $cmd &>/dev/null; if [ $? -ne 0 ]; then cat >&2 <<EOF You don't seem to have the $cmd program. |