aboutsummaryrefslogtreecommitdiff
path: root/ponysay
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-07-18 16:47:57 +0200
committerMattias Andrée <maandree@operamail.com>2012-07-18 16:47:57 +0200
commitd5932f72bda95f3e1b84909f4b3eb9e632b89171 (patch)
tree5583e42e026f85f9bb94bf45f7d6f5435228eb83 /ponysay
parent14f56dc33eba5d9ce24fe483456f20dccd251f84 (diff)
downloadponysay-d5932f72bda95f3e1b84909f4b3eb9e632b89171.tar.gz
ponysay-d5932f72bda95f3e1b84909f4b3eb9e632b89171.tar.bz2
ponysay-d5932f72bda95f3e1b84909f4b3eb9e632b89171.zip
support for multiple -f
Diffstat (limited to 'ponysay')
-rwxr-xr-xponysay8
1 files changed, 7 insertions, 1 deletions
diff --git a/ponysay b/ponysay
index 27ddfc5..a5edea0 100755
--- a/ponysay
+++ b/ponysay
@@ -115,12 +115,14 @@ say() {
fi
}
+ponies=()
+
while getopts f:W:lhv OPT
do
case ${OPT} in
v) version; exit ;;
h) usage; exit ;;
- f) pony="$OPTARG" ;;
+ f) ponies+=( "$OPTARG" ) ;;
l) list; exit ;;
W) wrap="$OPTARG" ;;
\?) usage >&2; exit 1 ;;
@@ -139,6 +141,10 @@ EOF
exit 1
fi
+if [[ ! ${#ponies[@]} == 0 ]]; then
+ pony="${ponies[$RANDOM%${#ponies[@]}]}"
+fi
+
if [[ ! -f $pony ]]; then
# Pony not a file? Search for it