BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

Anyone know how to stop cpan fscking with the color of my terminal?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW It is as I've been saying!(Audio until 20090817)

Replies are listed 'Best First'.
Re: They've fscked with CPAN.pm again
by Anonymous Monk on Sep 10, 2009 at 20:26 UTC

      Tried

      o conf colorize_output 0 o conf commit

      And it still fscks with my colors.

      Tried undef and:

      c:\test>cpan ←[32m cpan shell -- CPAN exploration and modules installation (v1.9402) Enter 'h' for help.←[0m cpan> o conf /color/ ←[32m$CPAN::Config options from ←[0m←[32m'C:\Perl64\ +lib/CPAN/Config.pm'←[0m←[32m:←[0m ←[32m←[0m ←[32m colorize_debug undef←[0m ←[32m colorize_output [undef]←[0m ←[32m colorize_print [green]←[0m ←[32m colorize_warn [red]←[0m ←[32m←[0m ←[32m←[0m

      Which doesn't look half as bad here as it does on my screen. They don't even bother to put stuff back as it was when you quit. Any other suggestions?

      Why oh why can't they make this shit opt-in instead of opt-out?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        What triggers the behaviour ?
        I have (I think) the same build of perl as you - namely the x64 build of perl-5.10.1 (build 1006), and I get that annoying behaviour only if I open the cpan shell but no compiler can be found (because I forgot to first run the batch file that will make it visible).

        If a compiler is not visible, the shell immediately changes color, and the download of MinGW automatically starts. (I suspect it's the 32-bit MinGW, too, which won't work with this build of perl anyway). I had assumed that ActiveState settings (not CPAN.pm) was responsible for all of this as the behaviour does not arise with perl-5.10.1 built from official perl 5.10.1 source .... but I haven't gone digging for the cause. (There is currently quite a bit of ActiveState-specific stuff built into ActivePerl.)

        I certainly don't get any of those ansi escapes you reported, possibly because my $ENV{TERM} is set to dumb, as already suggested by Anonymous Monk. Not sure if that's an option for you, but it may help if you're open to it.

        I take it you're running the cmd.exe shell.

        Cheers,
        Rob

        Are you sure it is "opt out?" Or is this specific to a certain platform? I've never had any coloring in my terminal on any number of OS X and Linux flavors on any of the 15 or more versions of CPAN I've used the shell with; on the most recent version now and it's just plain terminal text.

        Maybe some package changed the settings on you...? This is what mine shows (I had no idea the settings existed till reading your post)-

        colorize_debug undef colorize_output undef colorize_print undef colorize_warn undef

        Update: solution-wise, you can probably find and edit your CPAN/MyConfig.pm to remove the settings.

Re: They've fscked with CPAN.pm again
by BrowserUk (Patriarch) on Sep 11, 2009 at 14:24 UTC

    Please note: I asked "how to disable colorisation", not "how to make it work", or "who enabled it by default", nor did I invite debate as to whether I should want to disable it.

      I asked "how to disable colorisation", not "how to make it work", or "who enabled it by default"

      In this particular instance, I think the solution lies (in part, at least) in altering sub _warn in lib/ActivePerl/Config.pm.

      At the beginning of that sub we have:
      unless (-t STDOUT) { print "\n$msg\n"; return; }
      Changing the (-t STDOUT) to (0) takes care of things nicely for me. (There's no doubt a less hamfisted approach that would also work.)

      Cheers,
      Rob
        There's no doubt a less hamfisted approach that would also work

        For example, this patch to lib/ActivePerl/Config.pm:
        --- Config.pm_orig Sun Sep 13 17:44:03 2009 +++ Config.pm Sun Sep 13 17:49:34 2009 @@ -304,6 +304,7 @@ unless ($console) { $console = Win32::Console->new(Win32::Console::STD_OUTPUT_HAND +LE()); } + my $current = $console->Attr(); my($col,undef) = $console->Size; print "\n"; $console->Attr($Win32::Console::FG_RED | $Win32::Console::BG_WHIT +E); @@ -311,7 +312,7 @@ $_ .= " " while length() < $col-1; print "$_\n"; } - $console->Attr($Win32::Console::ATTR_NORMAL); + $console->Attr($current); print "\n"; }
        Cheers,
        Rob
      So you want people to help you disable it, without knowing who enabled it or where they did it?

        I asked if anybody knew!. In your case, I think the answer is fairly obviously "no".


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.