Shell Script Interfaces
Argument Default
Name an Input
A script interface starts with the values callers can pass. Defaults keep the command predictable when an argument is omitted.
Program
Play the script to choose a modeled first argument and see the effective project name.
argument_default.sh
#!/usr/bin/env bash
arg_project=
project="${arg_project:-demo}"
echo "project=$project"
#!/usr/bin/env bash
arg_project=
project="${arg_project:-demo}"
echo "project=$project"
argument
A script argument is caller-provided input.
default
`${name:-fallback}` supplies a fallback when the input is empty.
interface value
Copying the effective value into a named variable makes later code easier to read.