Created
June 19, 2026 08:22
-
-
Save namikingsoft/af0c445d5651d9a739ec25b691fbebf1 to your computer and use it in GitHub Desktop.
Bash Arguments Example
This file contains hidden or 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
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| usage() { | |
| echo "Usage: bash compare.sh --head <branch> --base <base_branch> [--dir <dirpath>]" | |
| exit 1 | |
| } | |
| BRANCH_NAME="" | |
| BASE_BRANCH="" | |
| DIR="test" | |
| while [[ $# -gt 0 ]]; do | |
| case "$1" in | |
| --head) BRANCH_NAME="$2"; shift 2 ;; | |
| --base) BASE_BRANCH="$2"; shift 2 ;; | |
| --dir) DIR="$2"; shift 2 ;; | |
| *) usage ;; | |
| esac | |
| done | |
| if [ -z "$BRANCH_NAME" ] || [ -z "$BASE_BRANCH" ]; then usage; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment