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

Re: apt-get remove/purge with regex gives unexpected result



On 2014-02-12 17:25 +0100, rpr nospam wrote:

> In order to uninstall all libreoffice packages I ran the following
> apt-get command with a simple regular expression:
>
> $ sudo apt-get remove 'libreoffice.*'
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> Note, selecting 'libreoffice.org-calc' for regex 'libreoffice.*'
> Note, selecting 'libreoffice.org-writer' for regex 'libreoffice.*'
> Package 'libreoffice.org-calc' is not installed, so not removed
> Package 'libreoffice.org-writer' is not installed, so not removed
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
>
> I'd say this output is unexpected because apt-get does not select
> installed libreoffice packages listed by dpkg-query.
>
> But if the regular expression starts with ^ I get the expected result:

The apt-get manpage contains the following paragraph:

  If no package matches the given expression and the expression
  contains one of '.', '?' or '*' then it is assumed to be a POSIX
  regular expression, and it is applied to all package names in the
  database. Any matches are then installed (or removed). Note that
  matching is done by substring so 'lo.*' matches 'how-lo' and
  'lowest'. If this is undesired, anchor the regular expression with
  a '^' or '$' character, or create a more specific regular
  expression.

My interpretation of that paragraph is that apt-get first tries to
interpret the pattern as a wildcard (see glob(7)) and only tries a
regular expression match if the glob produces no matches.

Cheers,
       Sven


Reply to: