Regression in "xmllint --xpath" return code, no longer matches documentation
We have been caught out by an xmllint return code changing from error to success, after an OS upgrade. Commands which previously halted execution now succeed.
The man page documents the behaviour as:
--xpath "XPath_expression"
[...] In case of an empty node set the "XPath set is empty" result
will be shown and an error exit code will be returned.
Whereas the actual behaviour has changed as below.
Previously the error code was 10 for "XPath evaluation error".
It doesn't seem to relate to XML on stdin, I just used this for convenience of a reproducable test case; our affected case uses an input file and exhibits the same problem.
# Alpine Linux 3.17
$ echo '<a>test</a>' | xmllint --xpath '//b' -; echo $?
XPath set is empty
10
$ xmllint --version
xmllint: using libxml version 21004
compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 HTTP DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Schemas Schematron Modules Debug Zlib Lzma
# Alpine Linux 3.18
$ echo '<a>test</a>' | xmllint --xpath '//b' -; echo $?
XPath set is empty
0
$ xmllint --version
xmllint: using libxml version 21106
compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 HTTP DTValid HTML C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps utomata Schemas Schematron Modules Debug Zlib Lzma
It also persists with a custom build from git HEAD: 21300-GITv2.12.0-233-ga9e73f11.