--regexp option doesn't work with some regexps
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@
belocs-
belocs-
libc6: usr/bin/locale
libc6: usr/bin/localedef
I didn't want the "localedef" ones, so I tried using the "--regexp" argument:
chris@
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.
Changed in apt-file: | |
assignee: | nobody → motu |
Changed in apt-file: | |
assignee: | motu → motureviewers |
Changed in apt-file: | |
status: | Fix Committed → Fix Released |
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$' fookb-plainx buildutils: usr/bin/freebsd-lex buildutils: usr/bin/ freebsd- yyfix
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/
freebsd5-
freebsd5-
ispell: usr/bin/findaffix
tetex-bin: usr/bin/fdf2tex
transfig: usr/bin/fig2ps2tex
vflib2: usr/bin/fwindex