aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/ps.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index faddf685..19292c98 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -1423,10 +1423,11 @@ static int header_line(int line, int rev)
{
if (!line) return 0;
- if (FLAG(b)) rev = 0;
-
- printf("%s%*.*s%s%s\n", rev ? "\033[7m" : "", -TT.width*!!FLAG(b), TT.width,
- toybuf, rev ? "\033[0m" : "", FLAG(b) ? "" : "\r");
+ if (FLAG(b)) puts(toybuf);
+ else {
+ printf("%s%-*.*s%s\r\n", rev?"\033[7m":"", rev?TT.width:0, TT.width, toybuf,
+ rev?"\033[0m":"");
+ }
return line-1;
}
@@ -1635,6 +1636,7 @@ static void top_common(
pos[-1] = '[';
if (!isspace(was) && isspace(is) && i==TT.sortpos+1) *pos = ']';
}
+ if (FLAG(b)) while (isspace(*(pos-1))) --pos;
*pos = 0;
lines = header_line(lines, 1);
}