mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-18 02:24:21 +01:00
Add support for passing through -W
This commit is contained in:
parent
0d3de45f02
commit
2ddfe9d19b
1 changed files with 6 additions and 3 deletions
9
ponysay
9
ponysay
|
@ -4,6 +4,7 @@ version=0.4
|
||||||
SYSTEMPONIES=/usr/share/ponies
|
SYSTEMPONIES=/usr/share/ponies
|
||||||
HOMEPONIES="${HOME}/.ponies"
|
HOMEPONIES="${HOME}/.ponies"
|
||||||
pony=
|
pony=
|
||||||
|
wrap=
|
||||||
|
|
||||||
cmd=cowsay
|
cmd=cowsay
|
||||||
[[ ${0} == *ponythink ]] && cmd=cowthink
|
[[ ${0} == *ponythink ]] && cmd=cowthink
|
||||||
|
@ -22,14 +23,16 @@ usage() {
|
||||||
echo " -v Show version and exit"
|
echo " -v Show version and exit"
|
||||||
echo " -h Show this help and exit"
|
echo " -h Show this help and exit"
|
||||||
echo " -f[name] Select a pony (Either a filename or a pony name)"
|
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
|
do
|
||||||
case ${OPT} in
|
case ${OPT} in
|
||||||
v) version; exit ;;
|
v) version; exit ;;
|
||||||
h) usage; exit ;;
|
h) usage; exit ;;
|
||||||
f) pony=$OPTARG ;;
|
f) pony="$OPTARG" ;;
|
||||||
|
W) wrap="$OPTARG" ;;
|
||||||
\?) usage >&2; exit 1 ;;
|
\?) usage >&2; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -57,4 +60,4 @@ fi
|
||||||
# Ponies use UTF-8 drawing characters. Prevent a Perl warning.
|
# Ponies use UTF-8 drawing characters. Prevent a Perl warning.
|
||||||
export PERL_UNICODE=S
|
export PERL_UNICODE=S
|
||||||
|
|
||||||
exec "$cmd" -f "$pony"
|
exec "$cmd" -f "$pony" "${wrap:+-W$wrap}"
|
||||||
|
|
Loading…
Reference in a new issue