Skip to content

Instantly share code, notes, and snippets.

@unsafe9
Created April 28, 2023 09:57
Show Gist options
  • Save unsafe9/2467bea8b6207c9a76ee47cf8b4698d7 to your computer and use it in GitHub Desktop.
Save unsafe9/2467bea8b6207c9a76ee47cf8b4698d7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Parse command line arguments
while [ $# -gt 0 ]; do
case $1 in
#--env=*) export ENV="${1#*=}"; shift;;
--env) export ENV="$2"; shift 2;;
*) args+=("$1"); shift;;
esac
done
# Validate parameters
if ! [[ "$ENV" =~ ^(dev|stg|prd)$ ]]; then
echo "Invalid environment: $ENV"
exit 1
fi
echo "Extra args:" "${args[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment