Skip to content

Commit

Permalink
Add support for passing through -W
Browse files Browse the repository at this point in the history
  • Loading branch information
heftig committed Feb 26, 2012
1 parent 0d3de45 commit 2ddfe9d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ponysay
Expand Up @@ -4,6 +4,7 @@ version=0.4
SYSTEMPONIES=/usr/share/ponies
HOMEPONIES="${HOME}/.ponies"
pony=
wrap=

cmd=cowsay
[[ ${0} == *ponythink ]] && cmd=cowthink
Expand All @@ -22,14 +23,16 @@ usage() {
echo " -v Show version and exit"
echo " -h Show this help and exit"
echo " -f[name] Select a pony (Either a filename or a pony name)"
echo " -W[column] The screen column where the message should be wrapped"
}

while getopts f:hv OPT
while getopts f:W:hv OPT
do
case ${OPT} in
v) version; exit ;;
h) usage; exit ;;
f) pony=$OPTARG ;;
f) pony="$OPTARG" ;;
W) wrap="$OPTARG" ;;
\?) usage >&2; exit 1 ;;
esac
done
Expand Down Expand Up @@ -57,4 +60,4 @@ fi
# Ponies use UTF-8 drawing characters. Prevent a Perl warning.
export PERL_UNICODE=S

exec "$cmd" -f "$pony"
exec "$cmd" -f "$pony" "${wrap:+-W$wrap}"

0 comments on commit 2ddfe9d

Please sign in to comment.