apt-mark's regex matching seems odd

Bug #1628654 reported by Brian Murray
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Triaged
Medium
Unassigned

Bug Description

[ 12:06PM 4528 ] [ bdmurray@speedy:~/source-trees/ubuntu-release-upgrader/upstream ]
 $ apt-mark showmanual \*vcard
2vcard
[ 12:07PM 4529 ] [ bdmurray@speedy:~/source-trees/ubuntu-release-upgrader/upstream ]
 $ apt-mark showmanual vcard\*
2vcard

I was surprised the latter option found a match.

 $ apt-cache policy apt
apt:
  Installed: 1.3~rc4ubuntu1
  Candidate: 1.3~rc4ubuntu1
  Version table:
 *** 1.3~rc4ubuntu1 500
        500 http://192.168.10.7/ubuntu yakkety/main amd64 Packages
        100 /var/lib/dpkg/status

Tags: xenial yakkety
Changed in apt (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Julian Andres Klode (juliank) wrote :

There are three types of patterns
(1) word
(2) fnmatch() style
(3) regex

They're all intermangled together, so: A bare word only matches a direct match. If it includes a special character like * then it tries matching a fnmatch pattern first, and if that fails, tries to match a regex. And these expressions are not anchored as you have noticed.

What you want to search for is probably vcard$ or ^vcard. In fact, always include a ^ or a $ when specifying expression, as that forces apt to do regex matching.

Now, it's of course annoying that it is this way, but it's not a bug. I hope we get patterns at some point, so you can search name(regex) without having to worry about this shit. But that's going to take a while.

I guess we can keep this bug open as the pattern tracking bug, unless we already have another one for that, so I'm marking that as triaged for now.

Changed in apt (Ubuntu):
status: New → Triaged
Revision history for this message
Julian Andres Klode (juliank) wrote :

To clarify what happened here:

(1) *vcard is an fnmatch() expression matching 2vcard

(2) vcard* is an unanchored regular expression matching 2vard.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.