When using the windows cmd window to run Drush, the bash color changing codes are printed out, so I see stuff like:
No code updates available. <-[0;33m<-[1m
[ok]<-[0m

Comments

brad.bulger’s picture

i am tempted to change the name of this to be just "are annoying", period. i am running on Ubuntu in bash and it is of no value to me to have warnings come out in an invisible yellow color. how can we get rid of that stuff altogether?

update: i asked before trying, bad user :) it's not a hard hack, but it would still be good if it was configurable. i edited includes/drush.inc and added this redefinition of the color strings to the _drush_print_log() function:

  $red = $yellow = $green = '[%s]';
starbow’s picture

@tatere, thanks for the tip.

mikeryan’s picture

Status: Active » Needs review
StatusFileSize
new2.25 KB

Here's a patch adding a -n/--nocolor option to suppress the color codes. I'm not really motivated, but if someone can work out the codes to color Windows command prompts, perhaps a better approach would be something like -h/--highlight=[none|Unix|Windows].

jonhattan’s picture

moshe weitzman’s picture

If it really looks bad for all windows clients, we should probably set this by default for them. Can we identify which terminals do not support it?

We just fixed the "invisible yellow color" issue.

moshe weitzman’s picture

Anyone willing to work on a patch which autodetects when to trigger nocolor? Or does nice coloring even for windows?

mikeryan’s picture

Autodetecting windows, and suppressing/using Windows colors, would be nice. I think having an explicit flag is still useful - it's also helpful to suppress the escape coding when running in a script, where you're dumping the output to a log/scanning for [error]/etc.

Here's a ref on Windows color-coding, no time to try it right now...

http://stackoverflow.com/questions/77744/how-can-i-change-the-text-color...

moshe weitzman’s picture

Title: Bash color changing codes are annoying in Windows cmd » Bash color changing codes don't work in Windows cmd
Status: Needs review » Fixed

committed.

moshe weitzman’s picture

Status: Fixed » Active

actually, i'll leave this open in case someone can come up with a solution that looks good on windows.

smk-ka’s picture

Version: All-Versions-2.0 »
Status: Active » Needs review
StatusFileSize
new1.24 KB

Two enhancements:
1. Since Windows doesn't support ANSI codes, color is always disabled for this OS
2. Added terminal color capabilities detection, we need at least tput colors 3 for red, yellow, and green.
Needs testing, except on Windows.

smk-ka’s picture

StatusFileSize
new1.24 KB

Slightly improved version redirecting STDERR to avoid error messages.

brad.bulger’s picture

works keen for me - no colors in my colorless term.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that this keeps colors working as desired on OSX.

One last question - the orginal report was that colors do not work within cmd shell on Windows. It seems like this patch will also disable colors for Cygwin shell, putty, etc. Is that desireable? Are those popular enough to matter?

smk-ka’s picture

StatusFileSize
new1.33 KB

D'oh, totally forgot about cygwin... that's easy, though: Windows command prompt doesn't have the TERM environment variable defined, while *nix based terminals do. New patch additionally looks for TERM on Windows.

moshe weitzman’s picture

Status: Reviewed & tested by the community » Fixed

committed. thx.

mikeryan’s picture

Running in a script spits out

tput: No value for $TERM and no -T specified

Which may cause some ops types a little anxiety... Any reason not to toss an @ on the exec('tput... call?

Thanks.

smk-ka’s picture

Status: Fixed » Needs review
StatusFileSize
new999 bytes

Based on the error message you gave I would rather assume that it is sufficient to always look for the presence of a TERM in the environment, not only on Windows systems. Attached follow-up patch does exactly that, tested on Windows, Cygwin, Linux. Could you please check if it works for you too?

netaustin’s picture

Status: Needs review » Reviewed & tested by the community

Looks fine; not getting that error when run in a script.

moshe weitzman’s picture

Status: Reviewed & tested by the community » Fixed

Committed - thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.