Skip to content

Instantly share code, notes, and snippets.

@skulbrane
Last active December 11, 2016 03:59
Show Gist options
  • Save skulbrane/1032a07f09dbfa0930ce7e17eb843b56 to your computer and use it in GitHub Desktop.
Save skulbrane/1032a07f09dbfa0930ce7e17eb843b56 to your computer and use it in GitHub Desktop.
Comprehensive bash parameter substitution docs @ [TLDP](http://www.tldp.org/LDP/abs/html/parameter-substitution.html)
#!/bin/bash
default_value=-1
value=${1:-$default_value}
echo value=$value
@skulbrane
Copy link
Author

${parameter-default} and ${parameter:-default} are almost equivalent. The extra : makes a difference only when parameter has been declared, but is null. - TLDP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment