Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 16
    BashPitfalls is something you'll like I think. Commented Dec 4, 2014 at 1:54
  • backlink from this article I wrote, thanks for the writeup Commented Dec 9, 2014 at 14:08
  • One reason for not using double quotes around variables in shell scripts is that in most editors syntax highlighting no longer emphasizes variable names then ;-) Commented Nov 18, 2022 at 9:26
  • @U.Windl you should report that as a bug to the maintainers of the editor you use. That would be very bad if their syntax highlighting encouraged bad coding practice. vim doesn't have that problem AFAICT. Neither does jed. Having said, shell code (especially Bourne-like ones) syntax highlight is virtually impossible to do reliably (or usefully). Commented Nov 18, 2022 at 9:34
  • 2
    There's a fourth case where people fail to quote properly: when you have a construct like "$( cmd "$var" )", many sophomores leave out one of the pairs of quotes, and are surprised when you tell them they haven't put in enough quotes. Some of them even argue that extra quotes would make it break up into "$( cmd " $var " )" Commented Feb 2, 2024 at 1:21