From ea2067aedd4509b664211dd9815563742a31921d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 5 Feb 2017 19:39:31 -0600 Subject: Bugfix: last field was padding to width with trailing spaces (oops), and when we can't query terminal size pad to 80 but add -w. --- toys/posix/ps.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'toys') diff --git a/toys/posix/ps.c b/toys/posix/ps.c index a28118fa..d72e3359 100644 --- a/toys/posix/ps.c +++ b/toys/posix/ps.c @@ -585,7 +585,7 @@ static void show_ps(void *p) pad *= sign; // If last field is left justified, no trailing spaces. - if (!field->next && sign<0) pad = -(len = width); + if (!field->next && sign<0) pad = 0; // If we truncated a left-justified field, show + instead of last char if (olen>len && len>1 && sign<0) { @@ -1144,7 +1144,9 @@ static void shared_main(void) if (!TT.width) { TT.width = 80; TT.height = 25; - terminal_size(&TT.width, &TT.height); + // If ps can't query terminal size pad to 80 but do -w + if (!terminal_size(&TT.width, &TT.height) && toys.which->name[2] == 's') + toys.optflags |= FLAG_w; } // find controlling tty, falling back to /dev/tty if none -- cgit v1.2.3