The Pitfalls of Shelling Out in Programming
This technical article from the Julia programming language blog critiques the common practice of "shelling out," which involves spawning a pipeline of connected programs via an intermediate shell. While convenient and supported by glue languages like Perl and Ruby, the author argues that this technique is fundamentally flawed. The analysis highlights three primary issues: metacharacter brittleness, where special characters in variables cause command failures or security vulnerabilities; indirection and inefficiency, as the extra shell process adds overhead and prevents direct parent-child process monitoring; and silent failures, where errors in shelled commands do not automatically trigger exceptions, leading to undetected bugs. Using Ruby and Bash examples, the text demonstrates how seemingly simple code can break when handling directory names with spaces or other special characters. The article posits that these problems are inherent to the technique itself, regardless of the programming language used. It serves as a prelude to discussing superior alternatives provided by the Julia language, aiming to educate developers on writing more robust, secure, and efficient code by avoiding unnecessary shell intermediaries.
Wire timeline
The Pitfalls of Shelling Out in Programming
This technical article from the Julia programming language blog critiques the common practice of "shelling out," which involves spawning a pipeline of connected programs via an intermediate shell. While convenient and supported by glue languages like Perl and Ruby, the author argues that this technique is fundamentally flawed. The analysis highlights three primary issues: metacharacter brittleness, where special characters in variables cause command failures or security vulnerabilities; indirection and inefficiency, as the extra shell process adds overhead and prevents direct parent-child process monitoring; and silent failures, where errors in shelled commands do not automatically trigger exceptions, leading to undetected bugs. Using Ruby and Bash examples, the text demonstrates how seemingly simple code can break when handling directory names with spaces or other special characters. The article posits that these problems are inherent to the technique itself, regardless of the programming language used. It serves as a prelude to discussing superior alternatives provided by the Julia language, aiming to educate developers on writing more robust, secure, and efficient code by avoiding unnecessary shell intermediaries.
JuliaLang - The Julia programming language