All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Peter Junos <petoju@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] ss: use compact output for undetected screen width
Date: Wed, 25 Dec 2019 12:36:07 -0800	[thread overview]
Message-ID: <20191225123607.38be4bdc@hermes.lan> (raw)
In-Reply-To: <20191223124716.GA25816@peto-laptopnovy>

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.  

> @@ -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;
	}

  reply	other threads:[~2019-12-25 20:36 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 [this message]
2019-12-26 13:06   ` Peter Junos
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=20191225123607.38be4bdc@hermes.lan \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.org \
    --cc=petoju@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.