aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Lezaeta <prflr88@gmail.com>2012-07-17 21:16:35 -0400
committerPablo Lezaeta <prflr88@gmail.com>2012-07-17 21:16:35 -0400
commitfa9d4f57091fb8c48eecb5a8819657e75db0d9ee (patch)
treec2a8dfaaf4b1cff434b27bf927ad0c8aab9504d3
parent1d4732ece50b48388a00db5dd091cd421169963b (diff)
parente20ae102e582c8e8b7f2f73d44c2fbc42072faee (diff)
downloadponysay-fa9d4f57091fb8c48eecb5a8819657e75db0d9ee.tar.gz
ponysay-fa9d4f57091fb8c48eecb5a8819657e75db0d9ee.tar.bz2
ponysay-fa9d4f57091fb8c48eecb5a8819657e75db0d9ee.zip
Merge remote-tracking branch 'upstream/master'
-rwxr-xr-xponysay51
1 files changed, 47 insertions, 4 deletions
diff --git a/ponysay b/ponysay
index 23c1313..8c85356 100755
--- a/ponysay
+++ b/ponysay
@@ -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.