Fixes fortune/cowsay.

This commit is contained in:
2026-09-07 17:48:04 -07:00
parent 308484c7a2
commit 97dbb80e2c

View File

@@ -1,7 +1,37 @@
if [ -f "/opt/homebrew/bin/fortune" ]; then # Display fortune (with cowsay if available) in interactive shells
if [ -f "/opt/homebrew/bin/cowsay" ]; then case $- in
/opt/homebrew/bin/fortune | /opt/homebrew/bin/cowsay *i*) ;;
else *) return 0 2>/dev/null || exit 0 ;;
/opt/homebrew/bin/fortune esac
fi
_fortune_cmd=""
if command -v fortune >/dev/null 2>&1; then
_fortune_cmd="fortune"
elif [ -x "/opt/homebrew/bin/fortune" ]; then
_fortune_cmd="/opt/homebrew/bin/fortune"
elif [ -x "/usr/games/fortune" ]; then
_fortune_cmd="/usr/games/fortune"
elif [ -x "/usr/local/bin/fortune" ]; then
_fortune_cmd="/usr/local/bin/fortune"
fi fi
if [ -n "$_fortune_cmd" ]; then
_cowsay_cmd=""
if command -v cowsay >/dev/null 2>&1; then
_cowsay_cmd="cowsay"
elif [ -x "/opt/homebrew/bin/cowsay" ]; then
_cowsay_cmd="/opt/homebrew/bin/cowsay"
elif [ -x "/usr/games/cowsay" ]; then
_cowsay_cmd="/usr/games/cowsay"
elif [ -x "/usr/local/bin/cowsay" ]; then
_cowsay_cmd="/usr/local/bin/cowsay"
fi
if [ -n "$_cowsay_cmd" ]; then
"$_fortune_cmd" | "$_cowsay_cmd"
else
"$_fortune_cmd"
fi
unset _cowsay_cmd
fi
unset _fortune_cmd