[pacman-dev] word-wrapping when not outputting to a tty
shiningxc at gmail.com
Wed Aug 26 18:18:51 EDT 2009
On Wed, Aug 26, 2009 at 9:46 PM, Oleg Finkelshteyn<olegfink at gmail.com> wrote:
> 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
> 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?
I am fine with that patch.
I would also be happy with "getcols() could return -1 when word
wrapping shouldn't be done."
Not sure which one is better. The latter would remove the need for any
More information about the pacman-dev