3 ms·
It's kind of ironic that the example of "simple" code is a shell command which has many hidden gremlins. Just off the top of my head: - It swallows extra space
by l0b0 6y ago
It's kind of ironic that the example of "simple" code is a shell command which has many hidden gremlins. Just off the top of my head:
- It swallows extra spaces between the arguments.
- If the first argument starts with a hyphen the behaviour is implementation-dependent.
- In Bash, if there's an exclamation mark anywhere except the last character of any argument Bash tries to do event lookup instead of treating the string as a literal.
More fun examples at https://unix.stackexchange.com/q/65803/3645 https://unix.stackexchange.com/q/65803/3645.
I would trust the second piece of code much more than the first, despite the complexity.
- d0mine 6y agoIt is not like c++ is bullet proof e.g., "Anything in C++ generally comes with its very own footgun." https://news.ycombinator.com/item?id=9670382 https://news.ycombinator.com/item?id=9670382