Package: psmisc Version: 21.6-1 Severity: normal Tags: patch A command like:
$ pstree | less prints terminal special codes to a plain pipe, resulting in ugly and unreadable stuff like: initESC(0^OqwqESC(Bamule ESC(0^OtqESC(Bartsd ESC(0^OtqESC(Batd ESC(0^OtqESC(B7*[bonobo-activati] ESC(0^OtqESC(Bcdparanoia Simply check wether stdout is a terminal via isatty(). Patch attached. -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (500, 'unstable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.11-1-k7 Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C) Versions of packages psmisc depends on: ii libc6 2.3.5-4 GNU C Library: Shared libraries an ii libncurses5 5.4-9 Shared libraries for terminal hand psmisc recommends no packages. -- no debconf information
diff -ur psmisc-21.6.old/src/pstree.c psmisc-21.6/src/pstree.c --- psmisc-21.6.old/src/pstree.c 2004-12-15 12:15:52.000000000 +0100 +++ psmisc-21.6/src/pstree.c 2005-09-03 21:00:57.000000000 +0200 @@ -785,10 +785,10 @@ * command-line options, if given. */ - if (!strcmp(nl_langinfo(CODESET), "UTF-8")) { + if (isatty(1) && !strcmp(nl_langinfo(CODESET), "UTF-8")) { /* Use UTF-8 symbols if the locale's character set is UTF-8. */ sym = &sym_utf; - } else if ((termname = getenv ("TERM")) && \ + } else if (isatty (1) && (termname = getenv ("TERM")) && \ (strlen (termname) > 0) && \ (setupterm (NULL, 1 /* stdout */, NULL) == OK) && \ (tigetstr ("acsc") > 0)) {