apt-file cannot search for patterns starting with -

Bug #801336 reported by Michal Suchanek
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apt-file (Debian)
Fix Released
Unknown
apt-file (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

 apt-file search -gtkmozembed
Unknown option: g
Unknown option: t
Unknown option: k
Unknown option: m
Unknown option: o
Unknown option: z
Unknown option: e
Unknown option: m
Unknown option: b
Unknown option: e
Option d requires an argument
apt-file version 2.4.2
(c) 2002 Sebastien J. Gross <email address hidden>

apt-file [options] action [pattern]
apt-file [options] -f action <file>
apt-file [options] -D action <debfile>

Configuration options:
    --sources-list -s <file> sources.list location
    --cache -c <dir> Cache directory
    --architecture -a <arch> Use specific architecture
    --cdrom-mount -d <cdrom> Use specific cdrom mountpoint
    --from-file -f Read patterns from file(s), one per line
                                        (use '-' for stdin)
    --from-deb -D Use file list of .deb package(s) as
                                        patterns; implies -F
    --non-interactive -N Skip schemes requiring user input
                                        (useful in cron jobs)
    --package-only -l Only display packages name
    --fixed-string -F Do not expand pattern
    --ignore-case -i Ignore case distinctions
    --regexp -x pattern is a regular expression
    --verbose -v run in verbose mode
    --dummy -y run in dummy mode (no action)
    --help -h Show this help.
    --version -V Show version number

Action:
    update Fetch Contents files from apt-sources.
    search|find <pattern> Search files in packages
    list|show <pattern> List files in packages
    purge Remove cache files

Interpreting options after command both disables searching for patterns starting with - and is in conflict with the help text that mandates putting options before command.

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: apt-file 2.4.2
ProcVersionSignature: Ubuntu 3.0-1.2-generic 3.0.0-rc3
Uname: Linux 3.0-1-generic x86_64
Architecture: amd64
Date: Thu Jun 23 22:37:02 2011
PackageArchitecture: all
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: apt-file
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Revision history for this message
Michal Suchanek (hramrach) wrote :
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thanks for your report.

Confirmed in oneiric. Usually Unix command use the '--' special flag to specify that there is no option in the remaining arguments. But apt-file protect the minus sign before passing it to zfgrep.

A possible fix would be to always protect the arguments passed to zfgrep like this:
--- /usr/bin/apt-file 2011-06-23 23:10:22.000000000 +0200
+++ ./apt-file.new 2011-06-23 23:13:04.000000000 +0200
@@ -355,7 +355,7 @@
         else {
             my $zgrep_pattern = $Conf->{pattern};
             $zgrep_pattern =~ s{^\\/}{};
- $zcat = "zfgrep $ignore_case $zgrep_pattern";
+ $zcat = "zfgrep $ignore_case -- $zgrep_pattern";
         }
     }
     my $regexp = eval { $Conf->{ignore_case} ? qr/$pattern/i : qr/$pattern/ };

You can then call:
apt-file search -- -gtkmozembed

Changed in apt-file (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
tags: added: patch
Revision history for this message
Michal Suchanek (hramrach) wrote : Re: [Bug 801336] Re: apt-file cannot search for patterns starting with -

apt-file never passes the minus sign to zfgrep, it fails parsing the
commandline.

Changed in apt-file (Debian):
status: Unknown → New
Changed in apt-file (Debian):
status: New → Fix Committed
Changed in apt-file (Debian):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apt-file - 2.5.1ubuntu1

---------------
apt-file (2.5.1ubuntu1) raring-proposed; urgency=low

  * Merge from Debian unstable (LP: #1073472). Remaining changes:
    - Fix location of Contents files for Ubuntu.

apt-file (2.5.1) unstable; urgency=low

  [ Thijs Kinkhorst ]
  * Fix searching for patterns that start with a '-'. This still requires
    specifying '--' before the pattern (closes: #631438, LP: #801336)
  * Unset env variables that may influence the behaviour of grep
    (closes: #617183).
  * Japanese translation of update-notifier text by Hideki Yamane
    (closes: #641199).
  * Improve man page layout and help output text. Thanks Jari Aalto for
    the patch! (Closes: #651695)
  * rapt-file: replace dpkg-architecture call with dpkg --architecture,
    obsoleting the depends-heavy recommendation on dpkg-dev. Thanks
    helix84 (Closes: #671225).
  * Checked for policy 3.9.3, no changes needed. Add explicit python
    recommendation, even though we transitively recommended it via
    python-apt already, to satisfy Lintian.
  * Add rapt-file manual page (Closes: #613005).

  [ Enrico Zini ]
  * rapt-file: Updated distribution names, now it works on wheezy.
    (Closes: #663592)
  * rapt-file: deal with missing /etc/apt/sources.list. (Closes: #636564)
 -- Chase Douglas <email address hidden> Wed, 31 Oct 2012 10:09:50 +0100

Changed in apt-file (Ubuntu):
status: Triaged → 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.