diff options
author | Mattias Andrée <maandree@operamail.com> | 2012-08-01 00:19:34 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2012-08-01 00:19:34 +0200 |
commit | e5b783e52858ae73d26c21464952323b9e3f320a (patch) | |
tree | 705e75e0e7a996cd962e3657ab45d8cccfdebac6 /pq4ps | |
parent | ccd12be1ebe10bbeb471c132a53c0b576a9dfa42 (diff) | |
download | ponysay-e5b783e52858ae73d26c21464952323b9e3f320a.tar.gz ponysay-e5b783e52858ae73d26c21464952323b9e3f320a.tar.bz2 ponysay-e5b783e52858ae73d26c21464952323b9e3f320a.zip |
partial merge of quotes into main
Diffstat (limited to 'pq4ps')
-rwxr-xr-x | pq4ps | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -0,0 +1,39 @@ +#!/bin/bash + +if [[ $# == 1 ]] && [[ "$1" == '-l' || "$1" == '--list' ]]; then + perl $0.pl | cut -d @ -f 1 | uniq +else + _ponies="$(perl $0.pl)" + ponies=() + + if [[ ! $# == 0 ]]; then + p="" + for arg in "$@"; do + p=$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 "/usr/share/ponysay/quotes/$f")" + + echo "-f" $p $q + fi +fi |