aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-02-06 16:07:57 -0600
committerRob Landley <rob@landley.net>2017-02-06 16:07:57 -0600
commit45c2c21396d26254258851b72d8d50db93730106 (patch)
tree346557e156b6ff822731cc1d99da5dce1523f400
parent544669ff968beee1f522d72b2d92d1570c59f3ef (diff)
downloadtoybox-45c2c21396d26254258851b72d8d50db93730106.tar.gz
Make tty size failure to enable -w (Elliott prefers that), and fix last field
to be left justified again.
-rw-r--r--toys/posix/ps.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index 9c38430a..d018f2b1 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -585,13 +585,13 @@ static void show_ps(void *p)
pad *= sign;
// If last field is left justified, no trailing spaces.
- if (!field->next && sign<0) pad = 0;
+ if (!field->next && sign<0) pad = -1;
// If we truncated a left-justified field, show + instead of last char
if (olen>len && len>1 && sign<0) {
width--;
len--;
- pad++;
+ if (field->next) pad++;
abslen = 0;
}
@@ -1145,7 +1145,7 @@ static void shared_main(void)
TT.width = 80;
TT.height = 25;
// 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')
+ if (!terminal_size(&TT.width, &TT.height) && toys.which->name[1] == 's')
toys.optflags |= FLAG_w;
}
@@ -1168,8 +1168,8 @@ void ps_main(void)
char *not_o;
int i;
- if (toys.optflags&FLAG_w) TT.width = 99999;
shared_main();
+ if (toys.optflags&FLAG_w) TT.width = 99999;
// parse command line options other than -o
comma_args(TT.ps.P, &TT.PP, "bad -P", parse_rest);