From: Peter Junos <petoju@gmail.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] ss: use compact output for undetected screen width
Date: Thu, 26 Dec 2019 14:06:15 +0100 [thread overview]
Message-ID: <20191226130615.GA29536@peto-laptopnovy> (raw)
In-Reply-To: <20191225123607.38be4bdc@hermes.lan>
On Wed, Dec 25, 2019 at 12:36:07PM -0800, Stephen Hemminger wrote:
> On Mon, 23 Dec 2019 13:47:16 +0100
> Peter Junos <petoju@gmail.com> wrote:
>
> > This change fixes calculation of width in case user pipes the output.
> >
> > SS output output works correctly when stdout is a terminal. When one
> > pipes the output, it tries to use 80 or 160 columns. That adds a
> > line-break if user has terminal width of 100 chars and output is of
> > the similar width.
> >
> > To reproduce the issue, call
> > ss | less
> > and see every other line empty if your screen is between 80 and 160
> > columns wide.
> >
> > Signed-off-by: Peter Junos <petoju@gmail.com>
>
> I would prefer that if the use pipes the command output to a pipe that
> the line length was assumed to be infinite.
Good point, this is used in min().
> > @@ -1159,7 +1159,13 @@ static int render_screen_width(void)
> > */
> > static void render_calc_width(void)
> > {
> > + bool compact_output = false;
> > int screen_width = render_screen_width();
> > + if (screen_width == -1) {
> > + screen_width = 80;
> > + compact_output = true;
> > + }
> > +
> > struct column *c, *eol = columns - 1;
> > int first, len = 0, linecols = 0;
> >
>
> With this patch, declarations and code are now mixed (more than before).
> I would expect something like:
>
> static void render_calc_width(void)
> {
> int screen_width, first, len = 0, linecols = 0;
> bool compact_output = false;
> struct column *c, *eol = columns - 1;
>
> screen_width = render_screen_width();
> if (screen_width == -1) {
> screen_width = INT_MAX;
> compact_output = true;
> }
Seems good, I'll send changed patch soon.
Thanks for review!
next prev parent reply other threads:[~2019-12-26 13:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-23 12:47 [PATCH] ss: use compact output for undetected screen width Peter Junos
2019-12-25 20:36 ` Stephen Hemminger
2019-12-26 13:06 ` Peter Junos [this message]
2019-12-26 13:07 ` [PATCH net-next] " Peter Junos
2020-01-02 18:42 ` David Ahern
-- strict thread matches above, loose matches on Subject: below --
2019-12-23 10:45 [PATCH] " Peter Junos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191226130615.GA29536@peto-laptopnovy \
--to=petoju@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox