Is the Unix shell ready for XML? (2006)
lbreyer.com
lbreyer.com
The libxo library allows an application to generate text,
XML, JSON, and HTML output using a common set of function
calls. The application decides at run time which output
style should be produced.
There is some work ongoing to convert FreeBSD utilities to support libxo [2] and a long thread on freebsd-arch [3][1] https://juniper.github.io/libxo/libxo-manual.html
[2] https://wiki.freebsd.org/LibXo
[3] https://lists.freebsd.org/pipermail/freebsd-arch/2014-July/0...
On the one hand, I think it would be interesting to see a truly OO shell for UNIX, but on the other hand I don't know if that's really necessary for a UNIX system.
I used powershell for some moderately complex workflow & reporting stuff but at the end was kind of on the fence about if I should have just scrapped it all and done it with traditional tools. It really felt like powershell made hard things easy but easy things hard. I don't think I would use powershell again unless there was absolutely no other choice.
That said, I'm not sure I would ever want to implement much in it other than typical systems automation stuff.
If you are automating a large organization -- Powershell has one massive edge, already deployed and able to be managed sanely via the domain management tools with a permission model around it.
Some large (30k+ machine) organizations actually have fairly decent sized research projects on best ways to automate deployments and system management. It ends up being far trickier than it appears on the surface and any tool blessed by MS and shipped by default has a huge edge. Powershell might not be great -- but it is already on the machine and the competition is batch files.
That being said I'm with you on your last statement. Jeff Snover has always said that Windows benefits from PS being OO because its configuration is API oriented. PS brings the kind of consistency to Windows that has typically been available in UNIX.
On a serious note though, wouldn't XML sed and awk just be XSLT transforms?
While it's not quite sed/awk (there isn't a programming language per se, just simple edit/select commands) xmlstarlet can do some of the things to an xml document that you might do to a text document with sed and uses xslt internally.
edit: new "Avoid Gratuitous Negativity" complience.
Shell will always have problems with handling bloated/overheaded data structures. In these situations using intermediary higher level languages would help.
PS: I'm sorry my first post is unintentionally against new rule. I just realized.
And because of this, unices come with at least one accompanying higher order scripting language like perl or python.
I am not a fan of the bourne shell syntax but you can write fairly large programs on it, and the idea itself of using other programs and piping it at the core and heart of unix.
Perl is tied with any modern unix for historical reasons, but it has been criticized for not really following the principles of unix really well.
One critique of the worse-is-better [1] philosophy (Unix), is the design starts cracking more as it's pushed to scale to its logical conclusion.
Of course, maybe the worse-is-better essay is inapplicable (and the author himself argued both sides under a pseudonym or two). And good design is a matter of degree; we could all critique the-right-thing representatives. But here I think it's a useful model to describe what's going on.
I'm a cli ninja (at least for many tasks I need to do daily for a measure.) even though I nearly never ever need it's expanded use cases like arrays or process substitution. For example the latest shellshock was the result of an extended use case where implications of it was not well thought.
"Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can." - Look at the samples: Emacs, MATLAB, Mozilla, Opera, Trillian, and Drupal. Really?
http://en.wikipedia.org/wiki/Jamie_Zawinski#Zawinski.27s_law...
Filenames with spaces (or quotes, or unicode characters, or control characters, or...) have wreaked many a seemingly ideal program which needs to iterate over files.
Even -0 fails with some file contents due to null bytes embedded in Unicode characters.
Perhaps this is for enterprise shells, so yes :-)
Also there are repls or shells intended to have common data structures for input and output. (look into powershell)
What I mean is, this sentense you wrote is content-free. What does it mean "it was not a problem"? That they managed to do and be productive without it?
In the same sense not having computers was not a problem for nearly 2 millenia since Christ. They've managed to get by without them.
Not having something is not a problem in general, when you don't know what you're missing. You only see the problem when you compare the faster and more productive workflow and the possibilities you'd get if you had something compared to coping without it.
Which is how inventions are made, compared to "well, what we got works for us".
>Shell is not intended for high level data processing.
That's a limitation of the shell, that could very well be bypassed, not some physical law.
One could imagine shells very well intended for high level data processing (and in fact people have built some of those -- heck, even the Lisp Machines qualify).
http://en.wikipedia.org/wiki/BSON
The main issue is that it doesn’t have arbitrary precision like, say, OpenTNL. That could probably be overcome somewhat with compressed streams.
It would also be nice to have a leaf-first format, or hints for depth-first or breadth-first traversal so that the stream could be processed as it’s received.
These are really old ideas so maybe I just haven’t stumbled onto a solution.
What a huge mess!
If any binary format wants to become a universal competitor to those, it:
- should offer some big advantages over the already established ASN.1, and
- should be significantly smaller and faster than compression of human-readable formats (e.g. json+gzip or xml+xz)
XML, as a medium of transmission of structured data, pales when compared to basically any other commonly used alternative in 2015, in ease of use, readability and available tooling.
Now, I enthusiastically agree with the underlying ideal of having programs communicate on the shell through data structures instead of through eight-bit bytes. Let's do that, be it XML or anything else.
Much better then your typical REST API.
On the negative side, we had to endure managers coming back from “XML conferences” and recommending we ditch our
Oracle or Sybase or whatever and replace it with an XML database, because XML.
On the plus side, vendors made sure to support it so to this day we have good tooling in Eclipse, VS, etc.
Also on the bad side they have gone crazy overboard so we have security issues like this:
https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Pr...
So I still have WS endpoint but I rewrote it to manually parse XML and avoid all the crappy extensions that they put in and I cannot disable.
So yeah, this is loaded… I am not promoting XML. It has its issues. Use what you like.