[Aptitude-devel] Bug#815690: aptitude: regression in version 0.7.6 wrt. cli search display through pipes

Norbert Kiesel nkiesel at gmail.com
Wed Feb 24 02:34:28 GMT 2016


Hi Manuel,

my goal was pretty simply: I wanted the output be nicely aligned even when
it's piped.  When I tried that using -F I thought that -F is just ignored.
However, as you have shown that is not the case.

Nevertheless, it seems that setting the width of columns does not work as I
expected:
# aptitude -F '%30p %d' search '~N'
icingacli
                         simple CLI tool for Icingaweb2 and its modules

icingaweb2-common
                         simple and responsive web interface for Icinga -
common files
libp8-platform-dev
                          Pulse-Eight's platform support library --
development files
libp8-platform2
                         Pulse-Eight's platform support library

aptitude -F '%30p %d' search '~N' | head -3
icingacli simple CLI tool for Icingaweb2 and its modules
icingaweb2-common simple and responsive web interface for Icinga - common
files
libp8-platform-dev Pulse-Eight's platform support library -- development
files

Apart from the p column wider than 30 characters for the non-piped output,
the piped version seems to ignore the width specification.

Perhaps I'm still not understanding how to correctly use this?  Is there a
way to have `aptitude search '~N' | head -3` produce aligned output?

Right now the only solution I see is something ugly like the following
# aptitude -F '%p %d' search '~N' | perl -ne 'printf("%-30s - %s\n", /(\S+)
(.+)/)' | head -3
icingacli                      - simple CLI tool for Icingaweb2 and its
modules
icingaweb2-common              - simple and responsive web interface for
Icinga - common files
libp8-platform-dev             - Pulse-Eight's platform support library --
development files


On Tue, Feb 23, 2016 at 12:19 PM, Manuel A. Fernandez Montecelo <
manuel.montezelo at gmail.com> wrote:

> Control: tags -1 + moreinfo unreproducible
>
>
> Hi,
>
> 2016-02-23 18:34 nkiesel:
>
>> Package: aptitude
>> Version: 0.7.6-1
>> Severity: normal
>>
>> Dear Maintainer,
>>
>> version 0.7.6 changed the way output formatting is handled for the CLI
>> version,
>> and I consider that a regression.
>>
>> I use something like `aptitude search '~N' > t; less t`.  This used to
>> truncate
>> the output, but aptitude honored the `-w` switch, thus `aptitude search -w
>> $COLUMNS > t; less t` worked in 0.7.4.
>>
>> 0.7.6 no longer allws that. Even specifying an output format using `-F` is
>> silently ignored as soon as the output is redirected or piped.
>>
>
> -F is honoured:
>
>    $ aptitude -w 60 -F '%p %v %V' search ~n^aptitude$
>    aptitude                       0.7.6-1        0.7.6-1
>    aptitude:i386                  <none>         0.7.6-1
>
>    $ aptitude -F '%p %v %V' search ~n^aptitude$ | cat
>    aptitude 0.7.6-1 0.7.6-1
>    aptitude:i386 <none> 0.7.6-1
>
>    $ aptitude -F '%p | %v | %V' search ~n^aptitude$ | cat
>    aptitude | 0.7.6-1 | 0.7.6-1
>    aptitude:i386 | <none> | 0.7.6-1
>
>
> And in general, everything works in the same way, except that it doesn't
> try to columnize the results and separates fields with single (instead
> of multiple) spaces.
>
> And that's because, ultimately, when piping or redirecting aptitude
> cannot know what will be the size on the other end, when viewing the
> results.
>
>
> I consider that a regression.  Actually, I never really understood why
>> aptitude
>> tried to recognize this situation in the first place.  If the idea is to
>> allow
>> an easier parsing, the caller should simply use a proper -F argument (of
>> course; this also no longer works with 0.7.6).  Or perhaps add a
>> `-m|--machine-
>> friendly` parameter that forces this output format.
>>
>
> I am not sure why you insist that it doesn't work and are so sure about
> it, when it obviously does.
>
>
> So please reconsider your decision wrt. redirection detection.  Minimally,
>> I
>> would expect that `-F` is honored.  But ideally aptitude should just stop
>> trying to be too smart here and simply produce the same output
>> independent of
>> if it goes to a terminal or something else.
>>
>
> See #445206, #496728 for arguments on the contrary, which is the reason
> why I worked on it in the first place.
>
>
> Cheers.
> --
> Manuel A. Fernandez Montecelo <manuel.montezelo at gmail.com>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/aptitude-devel/attachments/20160223/7e7ae871/attachment.html>


More information about the Aptitude-devel mailing list