GNOME Bugzilla – Bug 554765
xmllint should validate quietly if no error
Last modified: 2021-02-20 16:21:34 UTC
When "xmllint --schema ..." is used to validate against a W3C XML Schema, successful validation results in a single line of output: "foo.xml validates". There are many automated-build situations where we prefer to run all tools silently unless there is a specific problem requiring attention. Thus, it would be preferable here for xmllint to be quiet about the validation success and simply exit with status 0. If this is considered undesirable in the general or default case, perhaps a "--quiet" flag could be added? I'd expect failed-validation error messages to still be printed under "--quiet", but if no errors arise, then no output should be produced.
that sounds a bit futile. If the "validates" error message disturbs you redirect it to /dev/null . The exit status should contain 0 id parsing and validation suceeded, if not it's a bug, Daniel
The "validates" message goes to stderr, same as any true error messages. One cannot trivially redirect the former to /dev/null without losing the later as well. So either I've got to filter stderr through something like "egrep -v ' validates$'", or I've got to run xmllint twice: once to check the exit status and a second time to get error messages if the exit status suggests there would have been some. Bleh.
Bahh send a patch to the list if you really care, should be trivial, right ? Daniel
Do you have a strong preference for removing the message entirely versus removing it only if a "--quiet" flag is given? If you have no preference, I'll favor simplicity and do the former.
changing the default behaviour is IMHO not an option, but others on the list may have a different opinion... Daniel
I agree that a --quiet option would be useful. Asynchronously filtering the "... validates" message only *and* retrieving the exit status is tricky, and AFAIK not portable. BTW, checking the exit status only to detect errors is not sufficient, so that one can be interested in messages too. See bug 710636.
A --quiet option was added here: https://gitlab.gnome.org/GNOME/libxml2/-/commit/02bee4c41444fa5c50e3b9ad5f851656b6d0b086