Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 270902 - [PATCH] Emerge outputs non-standard text
Summary: [PATCH] Emerge outputs non-standard text
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-23 06:32 UTC by Roger
Modified: 2015-06-11 21:02 UTC (History)
1 user (show)

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 Roger 2009-05-23 06:32:53 UTC
Emerge outputs the following (^H backspace?) non-standard text:

These are the packages that would be merged, in order:

Calculating dependencies  ... . ..^H^H... done!
[ebuild     U ] media-video/mjpegtools-1.9.0 [1.8.0-r1]

 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

This problem is incurred if a user sends the output of emerge to a text file.  (More notably, sending it to nail - a mail command - will cause the text file to be appended to an email as binary content instead of inline text.)

Reproducible: Always

Steps to Reproduce:
1. emerge -uDNpv --color -n world > test.txt
2. vi test.txt





A quick hack is to use the following pipe:

emerge -uDNp --color n world | tr -d '\010' | mail -s "Portage Update" root

Or, just in case we come across any other non-text characters (for kicks):

emerge -uDNp --color n world | tr -d '\015\032\010' | mail -s "Portage Update" root


(For the past months, I'm also seeing a lot of other /etc/cron.* scripts - using other programs - creating mails with these special characters.)
Comment 1 Roger 2009-05-23 08:46:57 UTC
=sys-apps/portage-2.2_rc33
Comment 2 Fabian Groffen gentoo-dev 2009-05-23 08:56:42 UTC
% echo -n ^H | od -c
0000000  \b

(^H = ctrl-v ctrl-h)

I think it's the spinner, I have the same and it's like this for a long while.  Never bothered me though ;)
Comment 3 Roger 2009-05-23 09:17:54 UTC
I'm filtering the ^H with tr when attaching emerge outputs to emails.


nail (/usr/bin/nail for /usr/bin/mail) is such a pain in the butt.

Any non-standard character and it wines & bundles the attached text to an email as binary!

Can close if this is standard output.  Thought I was catching something here.
Comment 4 Fabian Groffen gentoo-dev 2009-05-23 09:28:34 UTC
look:

line 11550 and 11551 of pym/_emerge/__init__.py read:

        if show_spinner:
            print "\b\b... done!"

I think the spinner should be disabled like colours are if the output is not a tty.  Maybe something like this:

Index: pym/_emerge/__init__.py
===================================================================
--- pym/_emerge/__init__.py     (revision 13625)
+++ pym/_emerge/__init__.py     (working copy)
@@ -11527,7 +11527,8 @@
                                        "would be merged, in order:\n\n"))
 
                show_spinner = "--quiet" not in self.myopts and \
-                       "--nodeps" not in self.myopts
+                       "--nodeps" not in self.myopts and \
+                       sys.stdout.isatty()
 
                if show_spinner:
                        print "Calculating dependencies  ",
Comment 5 Roger 2009-06-13 03:16:48 UTC
This would make sense.

If the output is a pipe (ie. "emerge -u world > blah.log" or "emerge -u world |tee blah.log" or "emerge -u world |mail ..."), then turn-off spinner for output.

Or, just add a switch "--no-spinner" and would be useful for the above situations?



Comment 6 Alex Xu (Hello71) 2015-06-11 21:02:17 UTC
$ tail -n +2914 pym/_emerge/actions.py | head -n 3
                if '--nospinner' in emerge_config.opts or \
                        emerge_config.target_config.settings.get('TERM') == 'dumb' or \
                        not sys.stdout.isatty():