Comment 3 for bug 381282

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 381282] Re: quiet mode (-q) should suppress "no matches" error

On Fri, 2009-06-05 at 23:57 +0000, Karl Fogel wrote:
> The practical consequence is that the program becomes more difficult to
> batch, because now the driver cannot assume that output on stderr means
> something went wrong (and if the output were moved to stdout, then the
> driver would not be able to assume that output means there are some
> matches). Instead, the driver has to parse the results just to learn
> there were no matches.

For all bzr programs, stderr output doesn't mean error, it means 'output
that wasn't the thing itself'. Progress bars, chatter, password prompts
and errors go to stderr to make scripting easier.

For batching, no matches should have an exit code of non-zero already,
so simply testing for ?$ != 0 should let you do flow control. If you
need more precise flow control I'd be delighted to put that in using
bzr's standard conventions.

> For humans users, it also violates the Principle of Least Surprise:
> people who run command-line search programs generally expect grep-like
> behavior, which is to print nothing if there were no hits.

$ grep foo bar
grep: bar: No such file or directory

I'm entertaining the idea of showing no output on a successful query
that finds no matches; however that is orthogonal to -q, as you note
below for grep.

> Finally:
>
> the help text for the -q flag says "Only display errors and warnings."
> Lack of hits is not an error or a warning; it's a perfectly normal
> result. Indeed, it may be the common case. I think the -q flag's
> current description is great; I just wished the flag actually behaved
> that way :-).

Well the -q flag is global; its inherited from the bzr command framework
- I'm not sure the description is really complete as it stands. What use
'diff -q' if you can't see the diff? I really consider -q as 'drop the
chatter', not 'drop the output'. And we agree that no matches is not
chatter :).

If what you really want is 'no output on no matches' and we can drop the
-q discussion, that might be more useful - you made some good points
vis-a-vis UI, but you haven't managed to do that with respect to -q
itself : I believe bzr-search is honouring -q for bzr at the moment
[mainly because bzr-search has no chatter].

-Rob