5 ms·
Piping isn't the culprit. It's what you pipe that is, and Unix Philosophy says "pipe whatever the hell you want, and let the users upstream sort it out". It's
by TeMPOraL 10y ago
Piping isn't the culprit. It's what you pipe that is, and Unix Philosophy says "pipe whatever the hell you want, and let the users upstream sort it out".
It's not about encoding everything in exactly the same way. It's about providing the basic, shared protocol for representing structure. With typical Unix tools, you don't have "simpler encodings", you have no encoding at all. Each tool outputs whatever its particular author felt like (and this changes between Unix systems), each tool parses things in whatever way its author felt like, and as a user your job is to keep transforming unstructured blobs of text to glue them together.
- jstimpfle 10y agoThere exists a shared protocol. It's called "explain it". But that's typically not even needed, the user can just look at the data and figure it out. > With typical Unix tools, you don't have "simpler encodings", you have no encoding at all. You don't even believe this yourself, do you? That's so obviously wrong. Name a well-thought out text file format that can't correctly be parsed e.g. by a Python one-liner with basic string operations. And please don't include: JSON, XML, YAML, sexps, because it's not possible, at least not without a library. Not needing special infrastructure is why these formats (often) win. Very obvious practical reasons. If you have applications where you need one of the above - go ahead and do it. Instead of trolling with this abstract, vague nonsense, it is better to propose a concrete case where existing practice is bad. Show how it should be done better. (And prepare to get contradicted).
- JoeAltmaier 10y agoI call "No True Scotsman"
- jstimpfle 10y agoI don't understand (sorry). Could you explain?
- JoeAltmaier 10y ago"All things like A are in category X. Except this long list I wrote, but they aren't really A, because I need my syllogism to work."
- jstimpfle 10y agoYou missed my cynism. I was opposed to these formats in the first place.
- JoeAltmaier 10y agoWhich seems at odds with the thesis, at least as far as I can figure it out.
- jstimpfle 10y agoLook again. For example I wrote "space-separated" in multiple places.
- TeMPOraL 10y ago> Name a well-thought out text file format that can't correctly be parsed e.g. by a Python one-liner with basic string operations. And please don't include: JSON, XML, YAML, sexps, because it's not possible, at least not without a library. Well, because this library should be a part of the OS API. A set of conrete cases where existing practice is bad is Unix itself (and its descendants). Think of every time a script breaks, does something unexpected, or introduces a security vulnerability, because every program has to contain its own, half-assed parser for textual data.
- jstimpfle 10y ago> because every program has to contain its own, half-assed parser for textual data. As I said, name me a format that I can't parse correctly as a Python one-liner. I work as a systems administrator and my scripts (mostly shell, python) don't break. I'm not kidding you. Of course when writing shell scripts (which I think you imply) I need to know how to write non-broken shell scripts (in a clean and straightforward way) and I will freely admit that it's not easy to learn how to do it. Partly because shell has some flaws, but more because of the insane amount of broken scripts and tutorials out there. But it's not even about defending shell. We are talking about text representation. > Well, because this library should be a part of the OS API. You are free to postulate that but it's won't make it less work. By the way "OS API" is ridiculous. These libraries have to be implemented for every language (and they have been, for most popular languages).
- TeMPOraL 10y ago> As I said, name me a format that I can't parse correctly as a Python one-liner. Sorry, I misread that in your previous comment as "name me a format that I can parse correctly with a Python one-liner, without special libraries". Anyway, the original article contains numerous examples of the issues I'm talking about; scroll to "Let’s begin with a teaser" and read from there. The point being, it's very difficult to correctly parse output in general case, because unstructured text doesn't reliably tell you when various data items begin and end. Most people thus won't bother with ensuring their ad-hoc parsing is correct. > By the way "OS API" is ridiculous. These libraries have to be implemented for every language (and they have been, for most popular languages). Sure each language has to implement its own bindings to the OS. My point is that there should be a structured format defined as standard on the system level, so that all CLI programs could use the same parser and generator instead of each rolling their own.
- Too 10y ago> There exists a shared protocol. It's called "explain it". But that's typically not even needed, the user can just look at the data and figure it out. This is the root cause of 99% of all parse errors and security holes in the world. If you just "look" on the output of ls in some arbitrary directory there is nothing there telling you that a file name can contain a newline that will mess up the output. Write your parser with this assumption and it's broken. (See OP) If i had a penny for every csv-"parser" I've seen that is just data=input.split(','); i would be a rich man now. Because the developer when looking at their data had no comma in any cell. Doesn't mean the customer don't have it.
- jstimpfle 10y agoI'm pretty sure most security errors come from implementations of complex binary formats. (Okay, there is the web world and I hear people still haven't learnt to escape their SQL queries). ls is only for human consumption. I said this elsewhere in this thread. CSV is utterly broken (at least was RFC'ed at some point, but the escaping rules are still shit. We have known for decades how to do it better).