Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 42 lines (33 sloc) 0.92 kb
#!/bin/bash
INSTALLDIR="$(dirname "$(dirname "$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )")")" # Get main bash script directory's parent
if [[ $# == 1 ]] && [[ "$1" == '-l' || "$1" == '--list' ]]; then
perl "$0.pl" "$INSTALLDIR" | cut -d @ -f 1 | uniq
else
_ponies="$(perl "$0.pl" "$INSTALLDIR")"
ponies=()
if (( $# > 1 )); then
p=()
for arg in "$@"; do
p+=( $(echo "$_ponies" | grep "^$arg@") )
done
_ponies=$p
fi
for _pony in $_ponies; do
ponies+=( $_pony )
done
if [[ ${#ponies[@]} == 0 ]]; then
ponies=()
for arg in "$@"; do
ponies+=( "$arg" )
done
p="${ponies[$RANDOM%${#ponies[@]}]}"
q='I am totally speechless'
echo "-f" $p $q
else
pony="${ponies[$RANDOM%${#ponies[@]}]}"
p="$(echo $pony | cut -d '@' -f 1)"
f="$(echo $pony | cut -d '@' -f 2)"
q="$(cat "$INSTALLDIR/share/ponysay/quotes/$f")"
echo "-f" $p $q
fi
fi
Jump to Line
Something went wrong with that request. Please try again.