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

Bug#693092: apt-utils: mishandles -o flags with empty values (-o foo="")



Control: reassign -1 libapt-pkg4.12 0.9.7.6
Control: tags -1 + patch

On 13 November 2012 07:29, Aaron M. Ucko <ucko@debian.org> wrote:
> apt-ftparchive ... -o APT::FTPArchive::Release::Version="" -o APT::FTPArchive::Release::Codename="testing" ... release dists/testing
>
> results in the error
>
> E: Invalid operation APT::FTPArchive::Release::Codename=testing
>
> It looks like apt-ftparchive is ignoring the = symbol and proceeding to
> take -o as the Version value and APT::FTPArchive::Release::Codename=testing
> as the operation.

The command line processor explicitly tests for a trailing “=” and
proceeds to consume the next argument if so (as though there was no
“=”).  This is handled twice: once for options (such as “-t=
unstable”), and again for arbitrary items (“-o foo= bar”).  The
first check will only consume the next argument if it does not begin
with “-” (that is, it does not *appear* to be another option).  The
later check will always consume the next argument.

This is a strange syntax to support.  It does not appear to be
documented, at least not in apt-get(8).  Do other programs support a
similar syntax (I don't know of any)?

At least these two checks should treat similarly a subsequent argument
starting with “-”, or just drop this syntax and consider “foo=” to
mean that the value of “foo” is empty, as per most other programs.

Attached are two patches that should resolve this either way.  Of
course, please disregard if this is actually some desired behaviour.

With empty-value.diff applied:
$ apt-get -t unstable download tf
…
$ apt-get -t=unstable download tf
…
$ apt-get -t= unstable download tf
E: Invalid operation unstable
$ apt-get -o APT::Default-Release unstable download tf
E: Option APT::Default-Release: Configuration item specification must
have an =<val>.
$ apt-get -o APT::Default-Release=unstable download tf
…
$ apt-get -o APT::Default-Release= unstable download tf
E: Invalid operation unstable
$ apt-get -o=APT::Default-Release=unstable download tf
…
$ apt-get -o=APT::Default-Release= unstable download tf
E: Invalid operation unstable
$ apt-get -oAPT::Default-Release=unstable download tf
…
$ apt-get -oAPT::Default-Release= unstable download tf
E: Invalid operation unstable

Attachment: arbitem.diff
Description: Binary data

Attachment: empty-value.diff
Description: Binary data


Reply to: