* [PATCH iproute2-next] ss: Remove trailing whitespace when output is not a TTY
@ 2026-02-18 21:19 Daniel Schulte
2026-02-25 18:23 ` Stephen Hemminger
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Schulte @ 2026-02-18 21:19 UTC (permalink / raw)
To: netdev; +Cc: David Ahern
Sometimes a value in the last column might be very long.
When grepping ss output the matched lines are also padded to the longest value.
In some cases this can result in multiple lines of the terminal getting filled
with spaces.
Don't print right padding in last visible column when ss can't determine the
screen width.
Signed-off-by: Daniel Schulte <trilader@schroedingers-bit.net>
---
misc/ss.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index b3566f6b..2cd6b470 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1211,7 +1211,7 @@ static int render_screen_width(void)
* aligned across lines. Available screen space is equally spread between fields
* as additional spacing.
*/
-static void render_calc_width(void)
+static bool render_calc_width(void)
{
int screen_width, first, len = 0, linecols = 0;
struct column *c, *eol = columns - 1;
@@ -1245,7 +1245,7 @@ static void render_calc_width(void)
if (compact_output) {
/* Compact output, skip extending columns. */
- return;
+ return compact_output;
}
/* Second pass: find out newlines and distribute available spacing */
@@ -1304,6 +1304,7 @@ newline:
len = 0;
linecols = 0;
}
+ return compact_output;
}
/* Render buffered output with spacing and delimiters, then free up buffers */
@@ -1311,7 +1312,8 @@ static void render(void)
{
struct buf_token *token;
int printed, line_started = 0;
- struct column *f;
+ struct column *f, *last_visible_column = 0;
+ bool compact_output = false;
if (!buffer.head)
return;
@@ -1321,11 +1323,18 @@ static void render(void)
/* Ensure end alignment of last token, it wasn't necessarily flushed */
buffer.tail->end += buffer.cur->len % 2;
- render_calc_width();
+ compact_output = render_calc_width();
/* Rewind and replay */
buffer.tail = buffer.head;
+ f = columns;
+ while (!field_is_last(f)) {
+ if (!f->disabled)
+ last_visible_column = f;
+ f++;
+ }
+
f = columns;
while (!f->width)
f++;
@@ -1340,7 +1349,8 @@ static void render(void)
/* Print field content from token data with spacing */
printed += print_left_spacing(f, token->len, printed);
printed += fwrite(token->data, 1, token->len, stdout);
- print_right_spacing(f, printed);
+ if (!compact_output || f != last_visible_column)
+ print_right_spacing(f, printed);
/* Go to next non-empty field, deal with end-of-line */
do {
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH iproute2-next] ss: Remove trailing whitespace when output is not a TTY
2026-02-18 21:19 [PATCH iproute2-next] ss: Remove trailing whitespace when output is not a TTY Daniel Schulte
@ 2026-02-25 18:23 ` Stephen Hemminger
2026-02-25 19:39 ` [PATCH netdev-next v2] " Daniel Schulte
0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2026-02-25 18:23 UTC (permalink / raw)
To: Daniel Schulte; +Cc: netdev, David Ahern
On Wed, 18 Feb 2026 22:19:53 +0100
Daniel Schulte <trilader@schroedingers-bit.net> wrote:
> Sometimes a value in the last column might be very long.
> When grepping ss output the matched lines are also padded to the longest value.
> In some cases this can result in multiple lines of the terminal getting filled
> with spaces.
>
> Don't print right padding in last visible column when ss can't determine the
> screen width.
>
> Signed-off-by: Daniel Schulte <trilader@schroedingers-bit.net>
Patch makes sense, but will not apply because either your mail system
is corrupting the patch or you are using an out of date version.
Please fix and resubmit
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH netdev-next v2] ss: Remove trailing whitespace when output is not a TTY
2026-02-25 18:23 ` Stephen Hemminger
@ 2026-02-25 19:39 ` Daniel Schulte
2026-02-28 1:10 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Schulte @ 2026-02-25 19:39 UTC (permalink / raw)
To: netdev; +Cc: dsahern, stephen, Daniel Schulte
Sometimes a value in the last column might be very long.
When grepping ss output the matched lines are also padded to the longest value.
In some cases this can result in multiple lines of the terminal getting filled
with spaces.
Don't print right padding in last visible column when ss can't determine the
screen width.
Signed-off-by: Daniel Schulte <trilader@schroedingers-bit.net>
---
Resubmitting as v2 using git send-email.
---
misc/ss.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index b3566f6b..2cd6b470 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1211,7 +1211,7 @@ static int render_screen_width(void)
* aligned across lines. Available screen space is equally spread between fields
* as additional spacing.
*/
-static void render_calc_width(void)
+static bool render_calc_width(void)
{
int screen_width, first, len = 0, linecols = 0;
struct column *c, *eol = columns - 1;
@@ -1245,7 +1245,7 @@ static void render_calc_width(void)
if (compact_output) {
/* Compact output, skip extending columns. */
- return;
+ return compact_output;
}
/* Second pass: find out newlines and distribute available spacing */
@@ -1304,6 +1304,7 @@ newline:
len = 0;
linecols = 0;
}
+ return compact_output;
}
/* Render buffered output with spacing and delimiters, then free up buffers */
@@ -1311,7 +1312,8 @@ static void render(void)
{
struct buf_token *token;
int printed, line_started = 0;
- struct column *f;
+ struct column *f, *last_visible_column = 0;
+ bool compact_output = false;
if (!buffer.head)
return;
@@ -1321,11 +1323,18 @@ static void render(void)
/* Ensure end alignment of last token, it wasn't necessarily flushed */
buffer.tail->end += buffer.cur->len % 2;
- render_calc_width();
+ compact_output = render_calc_width();
/* Rewind and replay */
buffer.tail = buffer.head;
+ f = columns;
+ while (!field_is_last(f)) {
+ if (!f->disabled)
+ last_visible_column = f;
+ f++;
+ }
+
f = columns;
while (!f->width)
f++;
@@ -1340,7 +1349,8 @@ static void render(void)
/* Print field content from token data with spacing */
printed += print_left_spacing(f, token->len, printed);
printed += fwrite(token->data, 1, token->len, stdout);
- print_right_spacing(f, printed);
+ if (!compact_output || f != last_visible_column)
+ print_right_spacing(f, printed);
/* Go to next non-empty field, deal with end-of-line */
do {
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-28 1:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-18 21:19 [PATCH iproute2-next] ss: Remove trailing whitespace when output is not a TTY Daniel Schulte
2026-02-25 18:23 ` Stephen Hemminger
2026-02-25 19:39 ` [PATCH netdev-next v2] " Daniel Schulte
2026-02-28 1:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox