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

Dieter Plaetinck dieter at plaetinck.be
Wed Aug 26 15:50:49 EDT 2009


On Wed, 26 Aug 2009 23:46:04 +0400
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
>                  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
> 

I've personally been bothered by this:
it's probably related/same issue:
pacman -Qi libsoup
(...)
Depends On     : glib2>=2.20.4  gnutls>=2.8.1  libxml2>=2.7.3  libproxy>=0.2.3  sqlite3>=3.6.15  gconf>=2.26.0-3  
(...)


pacman -Qi libsoup | grep Depends
Depends On     : glib2>=2.20.4  gnutls>=2.8.1  libxml2>=2.7.3  libproxy>=0.2.3 

Dieter


More information about the pacman-dev mailing list