Created
October 19, 2021 13:50
-
-
Save msewell/298ee55df07b81963f3b82fe0d97c5af to your computer and use it in GitHub Desktop.
Template: Basic shell script with launch arguments
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
#!/bin/bash | |
# The "<name you would refer to this script as in conversation with your team members>" script | |
# | |
# This script does <thingA> and <thingB> by way of <thingC>. | |
# It is generally used for <purpose>. | |
# | |
# Usage example: script.sh --some-argument=true --some-other-argument=false | |
# | |
# # This shell script follows the conventions set by the Google shell styleguide: https://google.github.io/styleguide/shellguide.html | |
set -o errexit # If any command returns a non-zero exit status, the script itself exits. | |
set -o pipefail # If any piped command returns a non-zero exit status, the script itself exits. | |
set -o nounset # Exit script if any variable is not set. | |
#set -x # Use for debugging this script. Prints each command to stdout before executing it. | |
# Parse launch arguments. | |
for i in "$@"; do | |
case $i in | |
--some-argument=*) | |
readonly some_argument="${i#*=}" | |
shift | |
;; | |
--some-other-argument=*) | |
readonly some_other_argument="${i#*=}" | |
shift | |
;; | |
*) | |
# unknown option | |
;; | |
esac | |
done | |
echo "This is where the script goes..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment