Skip to content

Instantly share code, notes, and snippets.

@jmorahan
Created April 27, 2017 11:28
Show Gist options
  • Save jmorahan/315c3838b7685511ff340f7ad3a9dbb6 to your computer and use it in GitHub Desktop.
Save jmorahan/315c3838b7685511ff340f7ad3a9dbb6 to your computer and use it in GitHub Desktop.
bash script default parameters variable
#!/bin/bash
declare -a DEFAULTS PARAMS
DEFAULTS=(foo bar "baz quux")
PARAMS=("${@:-${DEFAULTS[@]}}")
printf "%s\n" "${PARAMS[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment