<div dir="ltr"><div>Hi Manuel,<br><br>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.<br><br>Nevertheless, it seems that setting the width of columns does not work as I expected:<br><span style="font-family:monospace,monospace"># aptitude -F '%30p %d' search '~N'<br>icingacli                                                                                            simple CLI tool for Icingaweb2 and its modules                                                              <br>icingaweb2-common                                                                                    simple and responsive web interface for Icinga - common files                                                <br>libp8-platform-dev                                                                                   Pulse-Eight's platform support library -- development files                                                  <br>libp8-platform2                                                                                      Pulse-Eight's platform support library                                                                      <br>aptitude -F '%30p %d' search '~N' | head -3<br>icingacli simple CLI tool for Icingaweb2 and its modules<br>icingaweb2-common simple and responsive web interface for Icinga - common files<br>libp8-platform-dev Pulse-Eight's platform support library -- development files<br><br></span></div><span style="font-family:monospace,monospace"></span>Apart from the p column wider than 30 characters for the non-piped output, the piped version seems to ignore the width specification.<br><span style="font-family:monospace,monospace"></span><div><br></div><div>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?<br><br></div><div>Right now the only solution I see is something ugly like the following<br><span style="font-family:monospace,monospace"># aptitude -F '%p %d' search '~N' | perl -ne 'printf("%-30s - %s\n", /(\S+) (.+)/)' | head -3<br>icingacli                      - simple CLI tool for Icingaweb2 and its modules<br>icingaweb2-common              - simple and responsive web interface for Icinga - common files<br>libp8-platform-dev             - Pulse-Eight's platform support library -- development files<br></span><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 23, 2016 at 12:19 PM, Manuel A. Fernandez Montecelo <span dir="ltr"><<a href="mailto:manuel.montezelo@gmail.com" target="_blank">manuel.montezelo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Control: tags -1 + moreinfo unreproducible<br>
<br>
<br>
Hi,<br>
<br>
2016-02-23 18:34 nkiesel:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Package: aptitude<br>
Version: 0.7.6-1<br>
Severity: normal<br>
<br>
Dear Maintainer,<br>
<br>
version 0.7.6 changed the way output formatting is handled for the CLI version,<br>
and I consider that a regression.<br>
<br>
I use something like `aptitude search '~N' > t; less t`.  This used to truncate<br>
the output, but aptitude honored the `-w` switch, thus `aptitude search -w<br>
$COLUMNS > t; less t` worked in 0.7.4.<br>
<br>
0.7.6 no longer allws that. Even specifying an output format using `-F` is<br>
silently ignored as soon as the output is redirected or piped.<br>
</blockquote>
<br>
-F is honoured:<br>
<br>
   $ aptitude -w 60 -F '%p %v %V' search ~n^aptitude$<br>
   aptitude                       0.7.6-1        0.7.6-1<br>
   aptitude:i386                  <none>         0.7.6-1<br>
<br>
   $ aptitude -F '%p %v %V' search ~n^aptitude$ | cat<br>
   aptitude 0.7.6-1 0.7.6-1<br>
   aptitude:i386 <none> 0.7.6-1<br>
<br>
   $ aptitude -F '%p | %v | %V' search ~n^aptitude$ | cat<br>
   aptitude | 0.7.6-1 | 0.7.6-1<br>
   aptitude:i386 | <none> | 0.7.6-1<br>
<br>
<br>
And in general, everything works in the same way, except that it doesn't<br>
try to columnize the results and separates fields with single (instead<br>
of multiple) spaces.<br>
<br>
And that's because, ultimately, when piping or redirecting aptitude<br>
cannot know what will be the size on the other end, when viewing the<br>
results.<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I consider that a regression.  Actually, I never really understood why aptitude<br>
tried to recognize this situation in the first place.  If the idea is to allow<br>
an easier parsing, the caller should simply use a proper -F argument (of<br>
course; this also no longer works with 0.7.6).  Or perhaps add a `-m|--machine-<br>
friendly` parameter that forces this output format.<br>
</blockquote>
<br>
I am not sure why you insist that it doesn't work and are so sure about<br>
it, when it obviously does.<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So please reconsider your decision wrt. redirection detection.  Minimally, I<br>
would expect that `-F` is honored.  But ideally aptitude should just stop<br>
trying to be too smart here and simply produce the same output independent of<br>
if it goes to a terminal or something else.<br>
</blockquote>
<br>
See #445206, #496728 for arguments on the contrary, which is the reason<br>
why I worked on it in the first place.<br>
<br>
<br>
Cheers.<span class="HOEnZb"><font color="#888888"><br>
-- <br>
Manuel A. Fernandez Montecelo <<a href="mailto:manuel.montezelo@gmail.com" target="_blank">manuel.montezelo@gmail.com</a>><br>
</font></span></blockquote></div><br></div>