mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-22 12:27:59 +01:00
Unbreak providing the message via argument. Whoops
This commit is contained in:
parent
7039eab517
commit
38f8c51bba
1 changed files with 19 additions and 5 deletions
20
ponysay
20
ponysay
|
@ -17,7 +17,9 @@ usage() {
|
||||||
version
|
version
|
||||||
echo
|
echo
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo "${0##*/} [options]"
|
echo "${0##*/} [options] [message]"
|
||||||
|
echo
|
||||||
|
echo "If [message] is not provided, reads the message from STDIN"
|
||||||
echo
|
echo
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -v Show version and exit"
|
echo " -v Show version and exit"
|
||||||
|
@ -26,6 +28,10 @@ usage() {
|
||||||
echo " -W[column] The screen column where the message should be wrapped"
|
echo " -W[column] The screen column where the message should be wrapped"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
say() {
|
||||||
|
exec "$cmd" -f "$pony" "${wrap:+-W$wrap}"
|
||||||
|
}
|
||||||
|
|
||||||
while getopts f:W:hv OPT
|
while getopts f:W:hv OPT
|
||||||
do
|
do
|
||||||
case ${OPT} in
|
case ${OPT} in
|
||||||
|
@ -36,9 +42,11 @@ do
|
||||||
\?) usage >&2; exit 1 ;;
|
\?) usage >&2; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
# Pony not a file? Search for it
|
|
||||||
if [[ ! -f $pony ]]; then
|
if [[ ! -f $pony ]]; then
|
||||||
|
# Pony not a file? Search for it
|
||||||
|
|
||||||
ponies=()
|
ponies=()
|
||||||
[[ -d $SYSTEMPONIES ]] && ponies+=( "$SYSTEMPONIES"/$pony.pony )
|
[[ -d $SYSTEMPONIES ]] && ponies+=( "$SYSTEMPONIES"/$pony.pony )
|
||||||
[[ -d $HOMEPONIES ]] && ponies+=( "$HOMEPONIES"/$pony.pony )
|
[[ -d $HOMEPONIES ]] && ponies+=( "$HOMEPONIES"/$pony.pony )
|
||||||
|
@ -52,7 +60,13 @@ if [[ ! -f $pony ]]; then
|
||||||
pony="${ponies[$RANDOM%${#ponies[@]}]}"
|
pony="${ponies[$RANDOM%${#ponies[@]}]}"
|
||||||
fi
|
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" "${wrap:+-W$wrap}"
|
if [[ -n "$*" ]]; then
|
||||||
|
# Handle a message given via arguments
|
||||||
|
say <<<"$*"
|
||||||
|
else
|
||||||
|
say
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue