On Thu, Sep 22, 2016 at 04:23:08AM -0600, Anthony J. Bentley wrote: > Hi, > > Unlike all the other software in the tree that checks terminal sizes, > ps(1) used to check the stdin and stderr terminal sizes as well as stdout. > When I unified the terminal size checks in the tree in March, I missed > this, and now "ps aux | blah" gets wrapped to 79 characters no matter > how big the terminal is. > > The below diff brings back the old behavior: if the output is a pipe, > ps will check if either stderr or stdin is a terminal and if so will use > its width. > > ok?
ok. It's nicer this way than the negated checks that were there in r1.69. > > Index: ps.c > =================================================================== > RCS file: /cvs/src/bin/ps/ps.c,v > retrieving revision 1.70 > diff -u -p -r1.70 ps.c > --- ps.c 17 Mar 2016 05:27:10 -0000 1.70 > +++ ps.c 22 Sep 2016 10:14:10 -0000 > @@ -105,7 +105,10 @@ main(int argc, char *argv[]) > termwidth = 0; > if ((cols = getenv("COLUMNS")) != NULL) > termwidth = strtonum(cols, 1, INT_MAX, NULL); > - if (termwidth == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0 && > + if (termwidth == 0 && > + (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0 || > + ioctl(STDERR_FILENO, TIOCGWINSZ, &ws) == 0 || > + ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == 0) && > ws.ws_col > 0) > termwidth = ws.ws_col - 1; > if (termwidth == 0) > Index: ps.1 > =================================================================== > RCS file: /cvs/src/bin/ps/ps.1,v > retrieving revision 1.108 > diff -u -p -r1.108 ps.1 > --- ps.1 8 Sep 2016 15:54:36 -0000 1.108 > +++ ps.1 22 Sep 2016 10:14:10 -0000 > @@ -543,8 +543,13 @@ If set to a positive integer, > output is formatted to the given width in columns. > Otherwise, > .Nm > -defaults to the terminal width \(mi 1, or 79 columns if the output is not a > -terminal. > +defaults to the terminal width \(mi 1, > +or 79 columns if none of > +.Dv stdout , > +.Dv stderr > +and > +.Dv stdin > +are a terminal. > .It Ev TZ > The time zone to use when displaying dates. > See >