[pacman-dev] word-wrapping when not outputting to a tty

Oleg Finkelshteyn olegfink at gmail.com
Wed Aug 26 15:46:04 EDT 2009


I've noticed the following behaviour which makes it somewhat difficult
to use -Qi/-Si/etc. in a pipeline:

$ pacman -Si binutils
...
Description    : A set of programs to assemble and manipulate binary
and object files
$ pacman -Si binutils | cat
Description    : A set of programs to assemble and manipulate binary and object
                 files

I'd expect pacman not word-wrapping the output in the second case, as
it breaks the line-oriented nature of data.
This happens because getcols() defaults to 80 when !isatty(1), but I'd
rather like it not to word-wrap at all in this case, as we're
outputting to something like a file or a pipe. In the former case,
some text processing tool could do better anyway, and the current
behavior makes the latter case hardly useful at all.

Does that make sense? Basically I'm suggesting (maybe) getting rid of
the isatty() check in getcols() and adding one around word-wrapping
code in indentprint() and list_display(). An attempt at implementing
the proposal above can be found at
http://rain.ifmo.ru/~olegfink/pacman-wrap.patch (sorry for not
inlining, I use gmail). Maybe there should be more code shared between
the two routines, e.g. getcols() could return -1 when word wrapping
shouldn't be done.

Any thoughts?

Thanks,
oleg


More information about the pacman-dev mailing list