Skip to content

Instantly share code, notes, and snippets.

@dermoth
dermoth / getopt.sh
Last active November 25, 2020 05:48
Bash + gnu getopt example
#!/bin/bash
set -eu
trap 'echo "$NAME: Failed at line $LINENO" >&2' ERR
NAME=${0##*/}
print_help() {
echo "Usage: $NAME <opts> <args>" >&2
exit 1
}