When an empty setting uses the fallback

A Bash configuration reader uses two parameter expansions shown below. Consider each row independently and complete the table with the text each expansion produces. Enter EMPTY for an empty result; otherwise enter the exact resulting word.


Shell
# Without colon
printf '%s\n' "${tag-cache}"

# With colon
printf '%s\n' "${tag:-cache}"


The empty-string row means that tag has been assigned an empty string. The final row means that it contains the word live. Record the expanded text before the newline added by printf.

State of tagWithout colonWith colon
Unset
Set to empty string
Set to live

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Bash Expressions Questions: