Quoting command line arguments the wrong way (2011)
That&#x27;s about Windows, but many uses of system() that involve non-static strings also probably get quoting wrong.<p>Of course, avoiding the shell is the best way to avoid the problem. Sometimes, you can&#x27;t avoid the shell.<p>My preferred shell quoting method, for unix, is to wrap each parameter in single quotes. Then only single quotes inside a parameter are a problem. They can be replaced with &#x27;&quot;&#x27;&quot;&#x27;<p>Probably a lot of things use double quotes and perhaps try to escape $ and &#x27; and &quot; but miss details to do with \ and perhaps other characters that some shells treat specially.<p>Another way is to pass the filename in the environment: system(&quot;rm -rf \&quot;$DIR\&quot;&quot;)