[Mono-bugs] [Bug 493776] New: System.Console.BufferWidth doesn't support pipes

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Apr 9 16:44:29 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=493776


           Summary: System.Console.BufferWidth doesn't support pipes
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: x86-64
        OS/Version: openSUSE 11.1
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jpryor at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


If you pipe the output of a program to less(1), Console.BufferWidth will be 0
(instead of the actual terminal width).  This causes the output of programs
which rely on Console.BufferWidth to have their output changed simply by piping
the output.

Example: sqlmetal (which uses Console.BufferWidth to choose how wide text
should be displayed).

No pipe:

  $ sqlmetal --help
  # lots of output omitted...
    /readLineAtExit                    Wait for a key to be pressed after
                                       processing.
  # ...

With a pipe:

  $ sqlmetal --help | less
  # lots of ouptut omitted...
    /readLineAtExit                    Wait
                                       for
                                       a
                                       key
                                       to
                                       be
                                       pressed
                                       after
                                       processing.
  # ...

Aside from being hilarious, the output is also unusable (who wants to read
that?!).

The underlying problem appears to be System.ConsoleDriver.IsConsole, which uses
isatty(3) to determine if the output is a terminal...which it won't be here (or
when e.g. redirecting output to a file).

I'm not sure what a proper fix is.  miguel suggested using either $COLS or
using 80 as a minimum width on IRC as a solution, but that doesn't seem
appropriate either...

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list