sagev6.0 interactive shell uses colors on prompt, even for dumb terminal

59 views
Skip to first unread message

Jskud

unread,
Jan 2, 2014, 11:54:19 PM1/2/14
to sage-s...@googlegroups.com
Describe the desired result and the context of the problem.

================================================================

Run Sage from a dumb terminal (eg, from an Emacs shell with
ansi-color-for-comint-mode-off and TERM=dumb).  You will see
unexpected terminal control characters around the prompt.

Platform (CPU) and Operating System
================================================================
Fails running Sage 6.0 on RHEL 5.7 on multi-core Pentium.

Fails running Sage 5.13 on Fedora release 16 (Verne) running on
Windows7 on multi-core Pentium using VirtualBox and downloaded image

Exact version of Sage (command: "version()")
================================================================
'Sage Version 5.13, Release Date: 2013-12-15'

Provide copy-paste-ready reproducible commands causing the error
================================================================

$ sage
sage: version()

==== you should see something like this ====

[[I've replaced the Esc control character with the two character ascii
representation (as Emacs would display it) "^[", and enabled
ansi-color midway through the example.]]

^[[0;34msage: ^[[0mversion()
^[[0;31m^[[0m'Sage Version 5.13, Release Date: 2013-12-15'
sage: "ansi-color-for-comint-on"
'ansi-color-for-comint-on'
sage: version()
'Sage Version 5.13, Release Date: 2013-12-15'
sage:

Other Information
================================================================

I suspect this is caused by either Sage or iPython not checking the
TERM setting.  This piece of code which sets colors = 'LightBG', may
be responsible; but of course, iPython could also be responsible for
doing the checking.

[[~/sage-5.13/devel/sage-main/sage/misc/interpreter.py]]

DEFAULT_SAGE_CONFIG = Config(
    PromptManager = Config(
        in_template = 'sage: ',
        in2_template = '....: ',
        justify = False,
        out_template = ''),
    TerminalIPythonApp = Config(
        display_banner = False,
        verbose_crash = True),
    TerminalInteractiveShell = Config(
        ast_node_interactivity = 'all',
        colors = 'LightBG' if sys.stdout.isatty() else 'NoColor',
        confirm_exit = False,
        separate_in = ''),
    # The extension is *always* loaded for SageTerminalApp
    # See the code for SageTerminalApp.init_shell
    #InteractiveShellApp = Config(extensions=['sage.misc.sage_extension']),
    )

[]

Volker Braun

unread,
Jan 3, 2014, 1:31:41 AM1/3/14
to sage-s...@googlegroups.com
Agree, dumb terminals are not taken into account. We could run "tput colors" to query the capabilities instead of assuming that every tty has colors. Feel free to open an trac ticket and fix it...
Reply all
Reply to author
Forward
0 new messages