Re: [PATCH] virt-xml-validate: Allow input to be read from stdin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2019-05-20 at 14:18 +0200, Martin Kletzander wrote:
> On Mon, May 20, 2019 at 11:57:13AM +0000, Johannes Holmberg wrote:
> > ---
> > 
> > Hello,
> > 
> > This is an updated version of a patch I submitted on 2015-06-10. I
> > got
> > some feedback on it but then moved on to a different project and
> > forgot about it. Anyway, I've updated the patch according to the
> > feedback so if you are still interested, here it is! :)
> > 
> 
> Hi, thanks for the patch.  Wouldn't it be easier and cleaner if we
> just did:
> 
> if [ "$XMLFILE" = "-" ]; then
>   XMLFILE=/dev/stdin
> fi
> 
> ??

I tried it but the problem is that if the SCHEMA-NAME argument is not
supplied, the validation needs two passes, one to read the root tag,
and another one to do the actual xml validation. If I use /dev/stdin
the second pass will (sometimes) fail because the input is already
exhausted.

It works if the input is redirected from a file:

$ ./virt-xml-validate - < asdf.xml 
/dev/stdin validates

But if I pipe it from another program it fails:

$ cat asdf.xml | ./virt-xml-validate -
/dev/stdin:1: parser error : Document is empty

 /Johannes


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux