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

Re: Aptitude ?narrow search



On Mon, May 03, 2010 at 11:15:27AM +0300, Panayiotis Karabassis <panayk@gmail.com> was heard to say:
> On 05/03/2010 01:28 AM, Daniel Burrows wrote:
> >>To illustrate suppose I want to search for package where a single
> >>version matches  "~A^unstable$",  "A^stable$" and "~i". A search
> >>where we expect no results. Yet:
> >>
> >   Why do you expect no results?  The three examples you posted below
> >look to me like they ought to be returned by that search.
> >
> So I am getting the results because a single installed version
> belongs to both stable and unstable (what I want), or, because an
> installed version from stable also has a version from unstable? I am
> still a little confused about ?narrows.

  Each of the packages you listed has a version that's installed and
that belongs to both stable and unstable (check packages.debian.org).

> aptitude search '~S ~A^unstable$ ~S A^stable$ ~i'
> 
> Does this do a search for installed versions from stable and then
> narrows the search to versions from unstable? Or  does it do a
> search for installed versions from stable *implicitly widens the
> match* and then searches for versions from unstable?

  This appears to be a bit confusing, and the documentation is wrong.

  ?narrow matches all the versions of a package against its first term.
Then it takes its second term and matches it against the versions the
first term matched.  So in the above line, you find a package in which
a version from unstable and from stable is installed.

  The documentation is wrong because it claims this is identical to
what ?any-version does.  Incidentally, I recommend using ?any-version
for what you're trying to do above; it should do the same thing, but
the behavior is more obvious.

  You can see the difference if you do this:

?narrow(?true, ?and(~A^testing$, ~i))

  That will do the same thing as:

?and(~A^testing$, ~i)

  On the other hand, it's not easy to find examples where ?narrow
behaves oddly -- you need to have a filter that matches several versions
at once, and all the examples I came up with were contrived (like the
one above).

  If you want a lot more detail about how search works, you can add

    -o 'aptitude::cmdline::debug-search=true'

  to the command-line.  You'll want to save the output to a file or pipe
it through less.

  Daniel


Reply to: