aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-02-05 19:39:31 -0600
committerRob Landley <rob@landley.net>2017-02-05 19:39:31 -0600
commitea2067aedd4509b664211dd9815563742a31921d (patch)
tree20c11149dbb46cf56142e5943c5ca5403fdcbd97
parentb4944cab5213e47be222f23dd60e86644e4f2186 (diff)
downloadtoybox-ea2067aedd4509b664211dd9815563742a31921d.tar.gz
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.
-rw-r--r--toys/posix/ps.c6
1 files changed, 4 insertions, 2 deletions
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