|
|
Subscribe / Log in / New account

Unix was a mistake

Unix was a mistake

Posted May 17, 2016 6:00 UTC (Tue) by felix.s (guest, #104710)
In reply to: Safename: restricting "dangerous" file names by farnz
Parent article: Safename: restricting "dangerous" file names

Exactly. It's just one of many, many pitfalls resulting from the "everything is a text file" principle: when it's in force, one program passing data to another (here — a list of files) has to serialise it into text, which the other program has to parse back. Both serialisation and parsing introduce potential for misinterpretations, bugs and unaccounted corner cases (say, failing to escape things properly). The potential is amplified when each program has its own parsing code written from scratch, which is very tempting when you deal with text (I recall a case, not that long ago, of someone using fscanf() to parse /etc/mtab, introducing an escaping bug, and then being told to use getmntent() instead). This cost of serialisation and parsing may be tolerable for one-time uses (when you know all the inputs that your program will ever process), but unacceptable when writing software that lasts.

If I were to design an operating system, I'd have the shell interpret command line arguments and pass them to programs as flags, abstract objects representing file paths (something like O_PATH file descriptors) and opened files (ordinary file descriptors). Pipelines would be based around passing abstract objects, not meaningless blocks of bytes. Incidentally, this would also improve security (because programs no longer need to access arbitrary file system locations) and solve so many other big and little problems (say, <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19165>; the compiler would no longer output text, it'd output objects representing diagnostics).

I think some of the advantages of this approach may be actually attainable on Linux today, by means of passing file descriptors over sockets and memfd. But to actually get to the root of the problem, I think you'd need to redesign Unix from scratch.

Bah, I got a bit carried away. But I had to let off this steam somewhere.


to post comments

Unix was a mistake

Posted May 17, 2016 6:37 UTC (Tue) by jem (subscriber, #24231) [Link]

Just as a side note: there is nothing in the Linux (or Unix) kernel that mandates that "everything is a text file". You could very well implement something like Windows Powershell. Pipes do not care if they convey binary data or text.

Unix was a mistake

Posted May 17, 2016 6:51 UTC (Tue) by viro (subscriber, #7872) [Link] (5 responses)

Yaaawn... Wake me up when you come up with mechanism for making that thing of yours strong-typed in any meaningful sense. And avoiding both the "rebuild the universe, we'd decided to change the type of that" problem and that of duhvelopers running wild with "extensible" APIs - the library API stability is already laughable due to that and you would apparently encourage that to even worse degree...

Unix was a mistake

Posted May 17, 2016 7:54 UTC (Tue) by dlang (guest, #313) [Link]

not to mention the idea that whatever object marshalling protocol you pick will be in sue in a few years, let alone a few decades.

Unix was a mistake

Posted May 17, 2016 9:18 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link] (3 responses)

Microsoft actually pulled it off with PowerShell. It's a very nice strongly typed shell language as the result.

Unix was a mistake

Posted May 17, 2016 14:56 UTC (Tue) by edgewood (subscriber, #1123) [Link] (1 responses)

And it's so nice that MS decided to create a Linux emulation layer so that developers could run bash.

Unix was a mistake

Posted May 17, 2016 15:07 UTC (Tue) by rahulsundaram (subscriber, #21946) [Link]

This is to entice Linux developers to use Azure more. Powershell is pretty nice regardless of that.

Unix was a mistake

Posted May 17, 2016 17:46 UTC (Tue) by dlang (guest, #313) [Link]

We'll see how well PowerShell stands the test of time, it's only been out for a couple releases now, and it's only the the last release that it became more than a toy. With Windows 10/Server 2016 we will have the second release with a full-blown PowerShell, but I am far more concerned about things a release or two down the road from that.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds