Friday 21 October 2016

Bash Parameter Substitution

Cited from How to tell if a string is not defined in a bash shell script?
  • ${var+blahblah}: if var is defined, 'blahblah' is substituted for the expression, else null is substituted
  • ${var-blahblah}: if var is defined, it is itself substituted, else 'blahblah' is substituted
  • ${var?blahblah}: if var is defined, it is substituted, else the function exists with 'blahblah' as an error message.

No comments:

Post a Comment