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
  • Thanks for all the trouble but your basic premise ignores the fact that bash normally uses an elaborate system of quote processing. But not in backquote expansion. Compare the following (which both give errors, but show the difference): ls "what is this" vs. ls `echo '"what is this"'` . Someone neglected to implement quote processing for the result of backquotes. Commented May 22, 2015 at 10:20
  • I'm glad backquotes don't do quote processing. The fact that they even do word splitting has caused enough confused looks, head-scratching and security flaws in modern computing history. Commented May 22, 2015 at 13:50
  • The question is "Isn't there some way to protect spaces in backtick (or $(...)) expansion?", so it seems appropriate to ignore processing that is not done in that situation. Commented May 22, 2015 at 13:53
  • The null-terminated element array format is the simplest and therefore safest way to express an array. It's just a shame that bash doesn't support it natively like apparently zsh does. Commented May 22, 2015 at 13:57
  • 1
    In fact, just this week I used printf "%s\0" and xargs -0 to route around a quoting situation where an intermediate tool would pass parameters through a string parsed by a shell. Quoting always comes back to bite you. Commented May 22, 2015 at 14:02