News for hackers. Stuff that matters.
Re:Pure sh bible – Posix sh alternatives to external processes by JdeBP on Wednesday October 21, 2020 @07:22AM (#24846681)
It's one of those things where the exact rules are complex and easy to misremember. Ironically, your two scripts demonstrate one way in which the problem arises. The rules are different for each script, because the command expansions are in different contexts. And when someone in the future decides to make your code into a shell function with local variables, suddenly the rules change again.

For maintainability, for safety, for the people who come after one, and for one's own sanity, the general advice is to always quote.

* https://mywiki.wooledge.org/Quotes

* https://unix.stackexchange.com/q/97560/5132

* https://unix.stackexchange.com/q/68694/5132

* https://unix.stackexchange.com/q/131766/5132

There are no comments on this comment yet.