Skip to content

Instantly share code, notes, and snippets.

@s-petit
Last active August 9, 2019 08:59
Show Gist options
  • Save s-petit/8af52ab756e4febe06fe28f6f238ab6a to your computer and use it in GitHub Desktop.
Save s-petit/8af52ab756e4febe06fe28f6f238ab6a to your computer and use it in GitHub Desktop.
bash script bootstrap
#!/bin/bash
usage="$(basename "$0") [-h --help] [-v A_VALUE] -- bash script description
where:
-h or --help shows this help text"
optspec=":-:"
while getopts "$optspec" optchar; do
case "${OPTARG}" in
h|help)
echo "$usage"
exit 1
;;
v)
value="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
YOUR_VALUE=${value}
;;
esac
done
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd ${CURRENT_DIR}
#Your code...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment