[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: dpkg -l needs wider package name output



On Mon, Apr 14, 2003 at 01:31:25PM +0100, Colin Watson wrote:
> On Tue, Apr 15, 2003 at 12:09:05AM +1200, Richard Hector wrote:
> > On Mon, Apr 14, 2003 at 04:18:21AM +0100, Colin Watson wrote:
> > > That's not true. What's actually happening is that, if COLUMNS isn't
> > > set, dpkg looks at its stdout to see whether it's a terminal, and if it
> > > is it tries to automatically detect the terminal size. When you pipe
> > > dpkg's output to less stdout is not a terminal so the autodetection
> > > fails.
> > > 
> > > In my own code I prefer to look at stdin rather than stdout to avoid
> > > this issue.
> > 
> > Isn't that even worse? That way if you were redirecting into a file,
> > either directly or indirectly, you'd still have your program thinking
> > it was talking to a terminal, and possibly screwing up the output (by
> > setting output widths, colours etc).
> 
> Turns out the code I was thinking of checks isatty(0) && isatty(1) ("are
> both stdin and stdout terminals?"), so that would solve that.

... but not the original problem. I don't see any way of detecting whether
there's a terminal at the end of a pipeline - other than user control via
commandline options.

Richard



Reply to: