#!/usr/bin/env bash: "${LIBBASH_DIR:?LIBBASH_DIR must be set. Please source libbash/init before other libraries.}"#------------------------------ Global Variables ------------------------------LIBBASH_USAGE_MSG=${LIBBASH_USAGE_MSG:-"[OPTIONS] ARGS"}#------------------------------ Private Functions -----------------------------#------------------------------ Public Functions ------------------------------# Show a usage messagefunction lb_show_usage(){printf"Usage: %s %s\n""${1}""${LIBBASH_USAGE_MSG}"}function lb_show_version(){printf"%s version %s\n""${1}""${2}"exit0}function lb_usage_error(){ lb_show_usage "${1}"printf"\nTry %s -h for more options.\n""${1}" >&2exit1}
Note
The message has a prefix of Usage:
lb_show_versionversion
Show the script version and exit with a status of 0.
#!/usr/bin/env bash: "${LIBBASH_DIR:?LIBBASH_DIR must be set. Please source libbash/init before other libraries.}"#------------------------------ Global Variables ------------------------------LIBBASH_USAGE_MSG=${LIBBASH_USAGE_MSG:-"[OPTIONS] ARGS"}#------------------------------ Private Functions -----------------------------#------------------------------ Public Functions ------------------------------# Show a usage messagefunction lb_show_usage(){printf"Usage: %s %s\n""${1}""${LIBBASH_USAGE_MSG}"}function lb_show_version(){printf"%s version %s\n""${1}""${2}"exit0}function lb_usage_error(){ lb_show_usage "${1}"printf"\nTry %s -h for more options.\n""${1}" >&2exit1}
lb_usage_error${0}
Show the script usage and help options and exit with a status of 1.
#!/usr/bin/env bash: "${LIBBASH_DIR:?LIBBASH_DIR must be set. Please source libbash/init before other libraries.}"#------------------------------ Global Variables ------------------------------LIBBASH_USAGE_MSG=${LIBBASH_USAGE_MSG:-"[OPTIONS] ARGS"}#------------------------------ Private Functions -----------------------------#------------------------------ Public Functions ------------------------------# Show a usage messagefunction lb_show_usage(){printf"Usage: %s %s\n""${1}""${LIBBASH_USAGE_MSG}"}function lb_show_version(){printf"%s version %s\n""${1}""${2}"exit0}function lb_usage_error(){ lb_show_usage "${1}"printf"\nTry %s -h for more options.\n""${1}" >&2exit1}