>Number:         164535
>Category:       bin
>Synopsis:       ps(1) truncates command to screen size even when stdout is not 
>a tty
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 27 09:50:09 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Marcus Reid
>Release:        9.0-STABLE
>Organization:
>Environment:
FreeBSD seabug 9.0-STABLE FreeBSD 9.0-STABLE #0: Mon Jan  9 10:53:27 PST 2012   
  root@seabug:/usr/obj/usr/src/sys/FARK  amd64
>Description:
ps(1) truncates long commands to the size of the screen even when stdout is not 
a terminal.  This is counter-intuitive and differs from another implementation 
I looked at.  Output of ps | grep differs depending on how big your terminal 
window is for example.
>How-To-Repeat:
ps aux | grep
ps auxww | grep
>Fix:
Patch included.  Tested; behavior remains consistent with docs: COLUMNS 
variable retains effect, and -w limits to 132 characters still.


--- bin/ps/ps.c.orig    2012-01-27 01:24:10.519024952 -0800
+++ bin/ps/ps.c 2012-01-27 01:24:20.350023629 -0800
@@ -187,6 +187,8 @@
 
        if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0')
                termwidth = atoi(cols);
+       else if (isatty(STDOUT_FILENO) == 0)
+               termwidth = UNLIMITED;
        else if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
             ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
             ioctl(STDIN_FILENO,  TIOCGWINSZ, (char *)&ws) == -1) ||


Patch attached with submission follows:

--- bin/ps/ps.c.orig    2012-01-27 01:24:10.519024952 -0800
+++ bin/ps/ps.c 2012-01-27 01:24:20.350023629 -0800
@@ -187,6 +187,8 @@
 
        if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0')
                termwidth = atoi(cols);
+       else if (isatty(STDOUT_FILENO) == 0)
+               termwidth = UNLIMITED;
        else if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
             ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
             ioctl(STDIN_FILENO,  TIOCGWINSZ, (char *)&ws) == -1) ||


>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"

Reply via email to