Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Often you will want to provide a default for arguments not explicitly provided by the user. This can be done using this rather odd syntax, with ":-" characters separating the positional argument number from the desired default. The entire defaulting construct is enclosed in "${ }".

Code Block
languagebash
textArg=${1:-"text default for 1st argument"}
integerArg=${2:-54321}

...

Importantly, auto_log reports an error and terminates script execution if no tag string is specified (we'll see much more on error handling shortly).

...