Leading me down the garden path today, how to quickly display an XML document … graphically, from the command line?
This doesn’t work:
$ virt-inspector --xml RHEL54.img | firefox -
Creating a temporary file is possible, but ugly.
There is no existing command line tool to generate data URIs, but we can write one in 3 lines of shell script:
#!/bin/sh - echo -n data:$1\; uuencode -m notused | tail -n +2 | tr -d '\n'
$ cat > /tmp/test.html <b>Hello,</b> <i>world!</i> $ datauri text/html < /tmp/test.html data:text/html;PGI+SGVsbG8sPC9iPgo8aT53b3JsZCE8L2k+Cg======
This also doesn’t work. There are two problems: the XML generated by virt-inspector is too long for a data URI, and in any case Firefox seems to ignore the data URI although I’m sure I’m constructing it correctly. Maybe it’s a security or configuration issue?
Well, good idea, but let’s go back to the temporary file idea. Bash process substitution might have worked:
$ firefox <(virt-inspector --xml RHEL54.img)
but Firefox’s frankly stupid session management crap gets in the way because this command expands to something like:
$ firefox /proc/self/fd/123
and the new firefox process passes the non-portable /proc/self path to the currently running instance of Firefox which doesn’t have the same view of /proc/self.
So we are finally left with:
$ firefox $(f=`mktemp -u`; virt-inspector --xml RHEL54.img > $f.xml; echo $f.xml)
which is fugly and unsafe.
If only there was a less insane tool to display XML, but being XML I guess insane goes with the territory.