[Aptitude-devel] Bug#834402: aptitude: search loses column format when redirected or piped

Manuel A. Fernandez Montecelo manuel.montezelo at gmail.com
Mon Aug 15 16:43:09 UTC 2016


Hi,

2016-08-15 11:59 Axel Beckert:
>Control: tag -1 + confirmed
>
>Hi Javier,
>
>Javier Cantero wrote:
>> Compare this:
>>
>> 	$  aptitude search "~i aptitude"
>> 	i   aptitude                                                    0.8.3-1        - gestor de paquetes basado en terminal
>> 	i A aptitude-common                                             0.8.3-1        - architecture independent files for the aptitude package manager
>>
>> with the same output piped through `less`:
>>
>> 	$  aptitude search "~i aptitude" | less
>> 	i  aptitude 0.8.3-1 - gestor de paquetes basado en terminal
>> 	i A aptitude-common 0.8.3-1 - architecture independent files for the aptitude package manager
>>
>> The same happens if the output is redirected to a file:
>>
>> 	$  aptitude search "~i aptitude" > kk.txt
>> 	$  cat kk.txt
>> 	i  aptitude 0.8.3-1 - gestor de paquetes basado en terminal
>> 	i A aptitude-common 0.8.3-1 - architecture independent files for the aptitude package manager
>
>Indeed. This looks like a regression from the version in Debian Jessie.
>
>> I've already read the discussion in #815690. but the thing is: piping to
>> more/less is a very common usage of aptitude search (since the lists of
>> packages tend to be very long), not just a special case for automatic
>> processing of the output. It's really annoying to have to remember to add
>> an arbitrary[*] width using `-w` in every `aptitude search ... | less`,
>> especially when it's a significant deviation from previous behaviour.
>
>I agree here, but I'm still not sure what's the best way to handle
>this case.

It's not a regression, or at least not an unintended one.  It was
directed to fix the problems described in #445206 and #496728.

The width given with -w is not arbitrary, it's the one that one wants
the lines to have (at least for me, it works differently if one sets 80,
100 or 160).  -w $COLUMNS should work fine if looking it directly in a
terminal, or if you want the pipe/redirection to have exactly the same
width as your current terminal.

In the past it was just hardcoded to "80 columns", so your example when
doing it with and without pipe/redirection will have looked different as
well -- unless the terminal that you are using is 80-column wide, of
course.  (See attachment, the description is truncated).


Cheers.
-- 
Manuel A. Fernandez Montecelo <manuel.montezelo at gmail.com>
-------------- next part --------------
$ aptitude search '~i~n^aptitude'
i   aptitude                                                                      - terminal-based package manager
i   aptitude-common                                                               - architecture independent files for the aptitude package manager

$ aptitude search '~i~n^aptitude' | cat
i   aptitude                        - terminal-based package manager
i   aptitude-common                 - architecture independent files for the apt


More information about the Aptitude-devel mailing list