mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-07 21:46:42 +01:00
Use heredocs, smarter check for cowsay
This commit is contained in:
parent
de9446ef97
commit
ae5e1176fe
1 changed files with 24 additions and 20 deletions
44
ponysay
44
ponysay
|
@ -6,16 +6,6 @@ HOMEPONIES="${HOME}/.ponies"
|
||||||
pony="*"
|
pony="*"
|
||||||
wrap=
|
wrap=
|
||||||
|
|
||||||
if [[ -f `which cowsay` ]];
|
|
||||||
then
|
|
||||||
true
|
|
||||||
else
|
|
||||||
echo "You don't seem to have the cowsay program."
|
|
||||||
echo "Please install it in order to use this wrapper."
|
|
||||||
echo -n "(Or symlink it to 'cowsay' in anywhere in \$path "
|
|
||||||
echo "if it actually exists under a different filename."
|
|
||||||
exit;
|
|
||||||
fi
|
|
||||||
cmd=cowsay
|
cmd=cowsay
|
||||||
[[ ${0} == *ponythink ]] && cmd=cowthink
|
[[ ${0} == *ponythink ]] && cmd=cowthink
|
||||||
|
|
||||||
|
@ -25,16 +15,19 @@ version() {
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
version
|
version
|
||||||
echo -e "\nUsage:"
|
cat <<EOF
|
||||||
echo "${0##*/} [options] [message]"
|
|
||||||
echo
|
Usage:
|
||||||
echo "If [message] is not provided, reads the message from STDIN"
|
${0##*/} [options] [message]
|
||||||
echo
|
|
||||||
echo "Options:"
|
If [message] is not provided, reads the message from STDIN
|
||||||
echo " -v Show version and exit"
|
|
||||||
echo " -h Show this help and exit"
|
Options:
|
||||||
echo " -f[name] Select a pony (Either a filename or a pony name)"
|
-v Show version and exit
|
||||||
echo " -W[column] The screen column where the message should be wrapped"
|
-h Show this help and exit
|
||||||
|
-f[name] Select a pony (Either a filename or a pony name)
|
||||||
|
-W[column] The screen column where the message should be wrapped
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
say() {
|
say() {
|
||||||
|
@ -56,6 +49,17 @@ do
|
||||||
done
|
done
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
|
if ! hash $cmd &>/dev/null; then
|
||||||
|
cat >&2 <<EOF
|
||||||
|
You don't seem to have the $cmd program.
|
||||||
|
Please install it in order to use this wrapper.
|
||||||
|
|
||||||
|
Alternatively, symlink it to '$cmd' in anywhere in \$PATH
|
||||||
|
if it actually exists under a different filename.
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ! -f $pony ]]; then
|
if [[ ! -f $pony ]]; then
|
||||||
# Pony not a file? Search for it
|
# Pony not a file? Search for it
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue