Created
August 8, 2019 00:20
-
-
Save aljp/b3aff30c16abb3a7f73152f1ca2a4876 to your computer and use it in GitHub Desktop.
A example of parsing optional bash script arguments using a `--KEY=VALUE` syntax
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
# https://unix.stackexchange.com/a/353639 | |
for ARGUMENT in "$@" | |
do | |
KEY=$(echo $ARGUMENT | cut -f1 -d=) | |
VALUE=$(echo $ARGUMENT | cut -f2 -d=) | |
case "$KEY" in | |
STEPS) STEPS=${VALUE} ;; | |
REPOSITORY_NAME) REPOSITORY_NAME=${VALUE} ;; | |
*) | |
esac | |
done | |
echo "STEPS = $STEPS" | |
echo "REPOSITORY_NAME = $REPOSITORY_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment