Skip to content

Instantly share code, notes, and snippets.

View janoskut's full-sized avatar

Janos Kutscherauer janoskut

  • Berlin, Germany
View GitHub Profile
@caruccio
caruccio / getopts.md
Last active May 22, 2024 13:27
Read shell options with positional arguments

This example shows how to read options and positional arguments from a bash script (same principle can be applied for other shells).

# some global var we want to overwrite with options
force=false
help=false
log=info
ARGS=() ### this array holds any positional arguments, i.e., arguments not started with dash

while [ $# -gt 0 ]; do