Bash
Parse command-line flags with getopts
Handle -v, -o FILE and -h in a bash script with getopts and a usage message.
Loading snippets…
5 snippets
Handle -v, -o FILE and -h in a bash script with getopts and a usage message.
A small CLI with a positional argument, flags, a main function and proper exit codes.
Archive a directory with a sortable timestamp and delete older backups beyond a retention count.
Clean up merged local branches safely, excluding main, master, develop and the current branch.
Fail fast on errors, unset variables and broken pipes, and clean up temp files with a trap.