From af39a2c46a6f899d298f63a270e8fd2338904ad3 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Mon, 27 Mar 2017 15:53:03 -0700 Subject: ps: don't query for terminal size if not a tty. `ps -A | cat` shouldn't have different output depending on the size of your terminal window. --- toys/posix/ps.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'toys/posix') diff --git a/toys/posix/ps.c b/toys/posix/ps.c index 0d79b5cb..f6906716 100644 --- a/toys/posix/ps.c +++ b/toys/posix/ps.c @@ -1149,8 +1149,10 @@ 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[1] == 's') - toys.optflags |= FLAG_w; + if (toys.which->name[1] == 's') { + if (!isatty(1) || !terminal_size(&TT.width, &TT.height)) + toys.optflags |= FLAG_w; + } } // find controlling tty, falling back to /dev/tty if none -- cgit v1.2.3