diff options
Diffstat (limited to 'ponysay')
-rwxr-xr-x | ponysay | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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 |