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*

14
  • 23
    Another reason to use double quotes is in case $DIRECTORY is not set for some reason. Commented Sep 15, 2008 at 22:41
  • 7
    "always wrap variables in double quotes...in a bash script." For bash, not technically necessary when using [[...]]; see tldp.org/LDP/abs/html/testconstructs.html#DBLBRACKETS (note: no word splitting): "No filename expansion or word splitting takes place between [[ and ]], but there is parameter expansion and command substitution." Commented Sep 12, 2014 at 1:31
  • 4
    Directories on Unix/Linux should not have any whitespaces, and subsequently scripts should not be adapted to it. It's bad enough Windows supports it, with all consequences to Windows scripting, but please, for the love of whatever, no need to introduce unnecessary requirements. Commented Dec 24, 2014 at 13:57
  • 33
    @tvCa I find that users generally prefer to be allowed more flexibility in their directory names rather than being forced to make things easier for developers. (In fact, when dealing with long file names, I find ones without spaces to be a pain as that kills word wrapping even though I myself have suffered in the past from not accounting for paths with spaces in scripts and programs.) Commented Aug 12, 2015 at 15:52
  • 8
    Ha. Spaces are just characters that have no glyphs usually. Anyway, you can escape them with a backslash. Commented Oct 18, 2016 at 8:27