Created
April 12, 2023 13:57
-
-
Save sebastiancarlos/122c674213320ab32875657f2c1d8652 to your computer and use it in GitHub Desktop.
Manimal - The Minimal POSIX-Compliant Man Pager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Manimal - The Minimal POSIX-Compliant Man Pager | |
# Manimal usage | |
manimal_usage() { | |
echo "Usage: manimal [-k] name" | |
echo | |
echo "Options:" | |
echo " -k Search for name in the utilities summary database" | |
} | |
# Manimal -k option | |
manimal_k() { | |
if [ "$1" == "manimal" ]; then | |
echo "manimal - The Minimal POSIX-Compliant Man Pager" | |
else | |
echo "No entry found for $1" | |
fi | |
} | |
# Check for arguments | |
if [ $# -eq 0 ]; then | |
manimal_usage | |
exit 1 | |
fi | |
# Parse options | |
while getopts ":k" opt; do | |
case $opt in | |
k) | |
shift | |
manimal_k "$1" | |
exit 0 | |
;; | |
\?) | |
echo "Invalid option: -$OPTARG" >&2 | |
manimal_usage | |
exit 1 | |
;; | |
esac | |
done | |
# Display Manimal man page | |
if [ "$1" == "manimal" ]; then | |
cat << EOF | |
Manimal - The Minimal POSIX-Compliant Man Pager | |
SYNOPSIS | |
manimal [-k] name | |
OPTIONS | |
-k Search for name in the utilities summary database | |
EOF | |
else | |
echo "No manual entry for $1" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment