Skip to content

Instantly share code, notes, and snippets.

@Caffe1neAdd1ct
Forked from warlord0/template.sh
Created October 21, 2021 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Caffe1neAdd1ct/a5318ef6efc60deeb528fb444c2dd9f0 to your computer and use it in GitHub Desktop.
Save Caffe1neAdd1ct/a5318ef6efc60deeb528fb444c2dd9f0 to your computer and use it in GitHub Desktop.
Bash Script Template
#!/bin/bash
EXAMPLE="example default"
# Plugin variable description
PROGNAME=$(basename $0)
RELEASE="Revision 1.0.0"
AUTHOR="(c) 2020 Warlord0"
# Functions plugin usage
print_release() {
echo "$RELEASE $AUTHOR"
}
print_usage() {
echo ""
echo "$PROGNAME $RELEASE - Bash Script Template"
echo ""
echo "Usage: $PROGNAME"
echo ""
echo " -h Show this page"
echo ""
echo " -e | --example Example argument"
echo ""
echo "Usage: $PROGNAME --help"
echo ""
exit 0
}
print_help() {
print_usage
echo ""
echo "Bash script template"
echo ""
exit 0
}
# Parse parameters
while [ $# -gt 0 ]; do
case "$1" in
-h | --help)
print_help
exit 0
;;
-v | --version)
print_release
exit 0
;;
-e | --example)
shift
EXAMPLE=$1
;;
*)
echo "Unknown argument: $1"
print_usage
;;
esac
shift
done
if [[ -z "${EXAMPLE}" || -z "${EXAMPLE}" ]]; then
echo "Missing argument"
exit 1
fi
# Script body goes after here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment