Source: aptitude
Version: 0.8.13-7ubuntu5
Severity: normal

Dear Maintainer,

I am attempting to write a script that parses the output of `aptitude search` formatted via a custom string passed alongside the `-F` argument.

For example, `aptitude  -F "%A %C %p" search '~b'` should list all broken packages, one per line, in three space-delimited columns (desired action, current state, and package name, respectively).

After seeing some weird output, I dug into the aptitude source code, and noticed at least two issues in `pkg_columnizer.cc` in the `debian-sid` (and `master`) branches of the aptitude source repository:

1) The first is that when showing the long-form version of the package's state (i.e. via `%C`), the state of a broken package is rendered as the single character `B`. The code for this is clearly seen at https://salsa.debian.org/apt-team/aptitude/-/blob/d24eb35bb7168169774b68b270b08f8079a2c9a5/src/pkg_columnizer.cc#L245-246.

2) The second is in the same source file when showing the long-form version of the pending action on the package (via `%A`). Particularly, while with the short-form `%a` (per lines 300-301), a package pending downgrade is rendered as a `w`, there is no equivalent conditional when using `%A`, which would seem to cause packages awaiting downgrade to render as 'none' in this column.

3) Lastly, in looking at the possible long-form outputs for these fields actions, I saw one more anomaly that probably doesn't rise to the level of "bug" but is nevertheless a departure from what is otherwise a convention: Specifically, |the pending ||action|| `||forbidden upgrade` is the sole action/state containing a whitespace character. All other values, (even, for example `||triggers-awaited`) contain hyphens in lieu of spaces even when a hyphen wouldn't be used in standard English. This, I imagine, was done to make the field easier when the output is used programmatically.|


Notes:
a) I'm an Ubuntu user, but this bug is clearly upstream in Debian, as seen in the source code. b) I wasn't sure whether this should be prioritized as `minor` or `normal`. I opted for `normal`, even though these errors are arguably spelling errors because, since this feature is supported to allow the creation of machine-parsable output, spelling errors actually do impact basic functionality. (Also, at least in 2, the output is objectively incorrect.) c) I do see that the git repo hasn't seen a commit to its main branches in over a year. I'm not sure if there's another VCS I should be looking at, but I at least see the error persists at https://sources.debian.org/src/aptitude/0.8.13-8.1/src/pkg_columnizer.cc

Thanks!
Mike Vastola


-- System Information:
Debian Release: forky/sid
APT prefers resolute-updates
APT policy: (500, 'resolute-updates'), (500, 'resolute-security'), (500, 'resolute-proposed'), (500, 'resolute')
Architecture: amd64 (x86_64)
Foreign Architectures: arm64

Kernel: Linux 6.17.0-41-generic (SMP w/32 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_CPU_OUT_OF_SPEC, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Thank you for using reportbug

Reply via email to