you are viewing a single comment's thread
view the rest of the comments
[–] 24 points 3 years ago* (1 child)
foo=ding
foobar=dong

echo \$foobar

Brackets make it explicit what you're trying to do. Do you want "dingbar" or do you want "dong"? I forget what the actual behavior is if you don't use brackets here, because I always use brackets for this reason now

  • source
  • parent
  • hideshow 2 child comments
  • [–] 5 points 3 years ago (1 child)

    I believe the actual behavior here would be printing β€œdong” as the shell interpreter is greedy in its evaluation of variables.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 2 years ago (1 child)

    the actual behavior here is to echo the literal string "$foobar", because the $ sign is escaped. so no variable expansion will take place at all.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 2 years ago (2 children)

    Oh lol. It doesn't show the $ at all on my mobile app till I escaped it

  • source
  • parent
  • hideshow 4 child comments