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.

15
  • 3
    Rather than be overly judgemental and label things as abominations like a wild-eyed zealot, it's far better and far more useful to strive to put Postel's Law into practice with every piece of code you write. Postel's Law is also known as the Robustness Principle and can be summarised as: "be conservative in what you send, be liberal in what you accept". While it needs to be applied with caution, it is a good part of the reason why the internet exists and doesn't suck anywhere near as much as it could, and why interoperability is possible. Commented Sep 6 at 16:14
  • 2
    You certainly shouldn't ignore, or deliberately sabotage, parts of a spec just because you don't like them or think they're too much trouble. Every character except NUL is valid in a pathname. Every character except NUL and / is valid in a filename. The posix spec allows newlines and other "annoying" characters in environment variable names and requires that applications "tolerate the presence of such names". If you fail to do that, it's not the file or variable names that are at fault, it's you and your code. Commented Sep 6 at 16:18
  • 1
    Also, as @emron's C code showed, shells are not the only source of environment variables. Pretty much every language has some trivial method to export them to the environment of child processes. And shells can obviously be child processes that inherit annoyingly-named variables from parent processes. Commented Sep 6 at 16:19
  • 2
    @GyroGearloose, Linus might have a say about how things are done by the Linux kernel, but not all of Unix-land is Linux. He's not god or king and he can't make e.g. the BSDs or commercial Unixen do things his way. Also, even the Linux kernel quite happily accepts pretty much any binary string in filenames. You might consider putting down the book you found those commandments in... Commented Sep 6 at 20:45
  • 2
    I'm not saying how or why applications should filter their inputs, just that they should. It's up to the application to make sure its input data is handled in a safe way. Commented Sep 7 at 1:02