Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 550556 - app-portage/portage-utils: colors should automatically disable with pipes/fifos
Summary: app-portage/portage-utils: colors should automatically disable with pipes/fifos
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Third-Party Tools (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage Utils Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-27 12:57 UTC by Toralf Förster
Modified: 2015-11-26 09:00 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Toralf Förster gentoo-dev 2015-05-27 12:57:03 UTC
Otherwise a command line like

$> qlist -C -I dev-qt | sed -e 's/^/~/g' -e 's/$/-4.8.7/g' > qt-4.8.7

produces a lot of "--- Invalid atom in " in the next emerge
FWIW "view <file>" often won't help - "cat <file>" however would show the mess
Comment 1 SpanKY gentoo-dev 2015-05-29 04:16:08 UTC
i think your example is incorrect.  the -C flag turns off colors and should work fine.  i'm pretty sure you mean the color behavior should be automatic when a pipe is detected.
Comment 2 Toralf Förster gentoo-dev 2015-05-29 10:50:26 UTC
(In reply to SpanKY from comment #1)
> i think your example is incorrect.  the -C flag turns off colors and should
> work fine.  i'm pretty sure you mean the color behavior should be automatic
> when a pipe is detected.
right - shown is the command to prevent escape sequences in the package file
Comment 3 SpanKY gentoo-dev 2015-06-06 06:05:42 UTC
hmm, this is just with pipes that we do this.  the main code does look for a tty, and it does turn things off when it's not.  so this works:
  qlist -I ... > foo

we've left the pipe part enabled so you can get colors when doing:
  qlist -I ... | less

but that does mean your case doesn't work:
  qlist -I ... | sed ... > foo

i'd prefer to not break the pager method for now since it's easy to use the -C flag when scripting
Comment 4 Jason Zaman gentoo-dev 2015-06-06 08:18:38 UTC
emerge -1 $(qlist -I sec-policy/)
does not work, -C is required above, any chance we can make this work too?
Comment 5 SpanKY gentoo-dev 2015-06-07 04:32:42 UTC
(In reply to Jason Zaman from comment #4)

it's the same scenario -- bash creates a pipe when capturing output like that, and we currently do not turn off colors for pipes
Comment 6 SpanKY gentoo-dev 2015-11-26 09:00:33 UTC
i don't want to get into creating another common command line option or plumbing in a magic env var, so i've just deleted the fifo check for now:
http://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9a800fe6ba0176691c81f42ef50dcf37976e74ca