For example, tables would be output with type info and proper unambiguous delimiting of some sort.
Unrelated to that I once wrote a program in the past several years ago as two distinct parts that communicated over a pair of Unix pipes; one part the GUI which embedded a web view and the other part which contained the program logic and which output HTML to stdout. The code was quite ugly, but anyway it did the job at the time.
But the idea of outputting JSON is somewhat in between this two things. But the main takeaway here IMO is the idea about outputting a specific format as controlled by a flag. Of course other tools have done this too in the past.
Consider a few Unix utilities reimplemented to work a bit tighter together in terms of how some data is represented, and using for example Cap’n Proto to serialize the data and piping that between them but also writing a library for destructively converting to plain text representation and then using some method or combination of methods for deciding when to use binary piping. For example,
- A user-provided flag. Tiresome to type.
- A user-provided environment variable. Problematic when mixing tools that implement serialization with pure plaintext tools.
- The shell could be aware of which programs implement this serialization and invoke them with the flags or env vars corresponding to whether or not each program on each side of each pipe in a pipeline supports the serialization. Possibly the way to go.
In this way one could incrementally rebuild the Unix tools to work this way without having to change everything at once and still being compatible with the universal interface of plaintext forever, since no-one wants nor can implement this in every Unix tool out there.
Once you have a couple of tools support this then the possibility for new ways to interact with pipelines becomes available.
I still love and will use the classic command-line. But in some situations the possibilities enabled by this would be very compelling indeed.
JSON (or another pure data serialization format) is much better in that regard, because then you only need to agree on some basic data structures at the boundary.
It wouldn't require special tools but it could work with them.
You could save the column headers, types and separator in extended attributes.
That would save a lot of repeated wasteful parsing and checking.
Both sides just default to plain text so it'll be backwards compatible.
How to Quickly and Correctly Generate a Git Log in HTML http://www.oilshell.org/blog/2017/09/19.html
Git Log in HTML: A Harder Problem and A Safe Solution http://www.oilshell.org/blog/2017/09/29.html
I'm interested in ideas for structured data over pipes, or even better a prototype and example programs :)