From d5932f72bda95f3e1b84909f4b3eb9e632b89171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Wed, 18 Jul 2012 16:47:57 +0200 Subject: [PATCH] support for multiple -f --- manuals/manpage.6 | 9 +++++---- ponysay | 8 +++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/manuals/manpage.6 b/manuals/manpage.6 index e25a560b..6a7587a8 100644 --- a/manuals/manpage.6 +++ b/manuals/manpage.6 @@ -52,7 +52,8 @@ Show version of program. List pony files. .TP .B \-f \fIname\fP -Select a pony (either a file name or a pony name.) +Select a pony (either a file name or a pony name.), you can use this options multiple times, +and one of the will be selected randomly. .TP .B \-W \fIcolumn\fP The screen column where the message should be wrapped @@ -87,9 +88,9 @@ ponysay was written by Erkin Batu Altunbaş with major contributions from Mattias Andrée, Sven-Hendrik Haase, Jan Alexander Steffens et al. .\" See file CREDITS for full list. .PP -This manual page was written by Louis Taylor -for the Debian project (and may be used by others), and edited -by Mattias Andrée . +This manual page was originally written by Louis Taylor +for the Debian project (and may be used by others), and edited by +Mattias Andrée for the official ponysay release. .br .PP This program is licensed under WTFPL. diff --git a/ponysay b/ponysay index 27ddfc56..a5edea0d 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