Last active
February 8, 2025 18:49
-
-
Save byBretema/32a116074c2d52d1b32c8bdc9d330d7f to your computer and use it in GitHub Desktop.
linux args 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
# v1 ------------------------------------------ | |
cleanup=0 | |
build_type="Debug" | |
cmake_gen="Ninja" | |
pos_args=() | |
show_usage() { | |
echo "Usage: build.sh [-c (Cleanup)] [-r (Release)] [-g (Generator xxx)]" | |
} | |
while [[ $# -gt 0 ]]; do | |
case $1 in | |
-c|--cleanup) | |
cleanup=1; shift;; | |
-r|--release) | |
build_type="Release"; shift;; | |
-g|--cmakegen) | |
cmake_gen="$2"; shift; shift;; | |
-*|--*) | |
show_usage; exit 1;; | |
*) | |
pos_args+=("$1"); shift;; | |
esac | |
done | |
# v2 ----------------------------------------------- | |
cleanup=0 | |
build_type="Debug" | |
cmake_gen="Ninja" | |
pos_args=() | |
show_usage() { | |
echo "Usage: build.sh [-c (Cleanup)] [-r (Release)] [-g (Generator xxx)]" | |
exit 1 | |
} | |
while [[ $# -gt 0 ]]; do | |
case $1 in | |
-c|--cleanup) | |
cleanup=1; shift;; | |
-r|--release) | |
build_type="Release"; shift;; | |
-g|--cmakegen) | |
cmake_gen="$2"; shift; shift;; | |
*|-*|--*) | |
show_usage;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment