Functions, Arguments and Parsing Options: $@, shift, getopts and a Good --help
A Bash function returns data on stdout and success through its exit code; variables inside it are global unless declared local, and scope is dynamic. We collect shared functions in a sourced library and use positional parameters, shift, getopts and a while/case pattern for long options to build Bookstore's bookstore-deploy.sh -e staging -v 1.4.2 --dry-run interface, a good --help text and a dry run based on printf %q.
15 Nov 2026
·
14 min
·
19