--regexp option doesn't work with some regexps

Bug #33485 reported by Chris Moore
8
Affects Status Importance Assigned to Milestone
apt-file (Ubuntu)
Fix Released
Medium
MOTU Reviewers Team

Bug Description

I wanted to find which package provides /usr/bin/locale.

If I search just for that string, I get 4 responses:

    chris@chrislap:~$ apt-file search /usr/bin/locale
    belocs-locales-bin: usr/bin/locale
    belocs-locales-bin: usr/bin/localedef
    libc6: usr/bin/locale
    libc6: usr/bin/localedef

I didn't want the "localedef" ones, so I tried using the "--regexp" argument:

    chris@chrislap:~$ apt-file --regexp search '/usr/bin/locale$'

But now I get no responses.

It turns out that $ doesn't work in the regular expression search to anchor a match to the end of the string.

The same happens if I search for regexps ending with '\z' or '\Z', both of which are supposed to anchor a match to the end of the string in Perl.

See attached patch for a fix.

Revision history for this message
Chris Moore (dooglus) wrote : patch to fix the problem

This fixes it by implcitly turning on "--fixed-string" and removing the $ if it appears at the end of the regexp with the --regexp flag in effect.

It does the same for \z and \Z too.

Examples of it working:

chris@chrislap:~$ /tmp/apt-file -x search '/usr/bin/firefox$'
firefox: usr/bin/firefox

chris@chrislap:~$ /tmp/apt-file -x search '/usr/bin/firefox\z'
firefox: usr/bin/firefox

chris@chrislap:~$ /tmp/apt-file -x search '/usr/bin/firefox\Z'
firefox: usr/bin/firefox

# find all programs in /usr/bin beginning with f and ending in x:

chris@chrislap:~$ /tmp/apt-file -x search '/usr/bin/f.*x$'
efax: usr/bin/fax
facturalux: usr/bin/facturalux
fcitx: usr/bin/fcitx
felix: usr/bin/flx
firedns: usr/bin/fdnsmx
firefox: usr/bin/firefox
flex: usr/bin/flex
flex-old: usr/bin/flex
fluxbox: usr/bin/fluxbox
fookb-plainx: usr/bin/fookb-plainx
freebsd5-buildutils: usr/bin/freebsd-lex
freebsd5-buildutils: usr/bin/freebsd-yyfix
ispell: usr/bin/findaffix
tetex-bin: usr/bin/fdf2tex
transfig: usr/bin/fig2ps2tex
vflib2: usr/bin/fwindex

Changed in apt-file:
assignee: nobody → motu
Zak B. Elep (zakame)
Changed in apt-file:
assignee: motu → motureviewers
Revision history for this message
Barry deFreese (bddebian) wrote :

Uploaded in apt-file_2.0.8ubuntu2. Please keep and eye out and close as fix released. Thank you.

Changed in apt-file:
status: Unconfirmed → Fix Committed
William Grant (wgrant)
Changed in apt-file:
status: Fix Committed → Fix Released
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.