Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dog strips colors of task output #112

Open
victorb opened this issue Nov 20, 2016 · 4 comments
Open

Dog strips colors of task output #112

victorb opened this issue Nov 20, 2016 · 4 comments
Assignees
Labels

Comments

@victorb
Copy link

victorb commented Nov 20, 2016

When using dog to run commands that prints out lines with colors, it seems like dog is stripping out the colors for some reason.

I have a project called Quickwiki that uses dog, and when running QUICKWIKI_DEBUG=1 go run main.go build ./wiki, it prints out colors.

But, when running QUICKWIKI_DEBUG=1 dog build-wiki, which runs the same command, the colors are stripped.

@xsb xsb added the bug label Nov 20, 2016
@xsb
Copy link
Member

xsb commented Jan 17, 2017

@victorbjelkholm sorry for replying so late. I can reproduce the error building your project but I can't reproduce it if I create a bash based dog task that prints text color escape sequences, in that case it works just fine.

I see you are using fatih's color package, I will try to reproduce it using it and hopefully fix it.

@ghost
Copy link

ghost commented Jan 18, 2017

Most terminal coloring libraries (and probably fatih's, too) don't output escapes when their output is piped to something that is not a TTY; they usually rely on isatty(3) to detect this. This behaviour usually makes sense; you don't want to pass the coloring escapes to utilities such as grep.

@xsb xsb self-assigned this Jan 19, 2017
@xsb
Copy link
Member

xsb commented Jan 21, 2017

@slapresta you are right, fatih/color package uses mattn/go-isatty to check if output needs to be colored or not. The behaviour is documented here.

// NoColor defines if the output is colorized or not. It's dynamically set to
// false or true based on the stdout's file descriptor referring to a terminal
// or not. This is a global option and affects all colors. For more control
// over each color block use the methods DisableColor() individually.
NoColor = !isatty.IsTerminal(os.Stdout.Fd()) || os.Getenv("TERM") == "dumb"

@victorbjelkholm I'm closing this issue.

@xsb xsb closed this as completed Jan 21, 2017
@ghost
Copy link

ghost commented Jan 21, 2017

Sorry, I didn't express myself clearly. I didn't mean that this wasn't an issue, I was just explaining what its cause could be. I believe that Dog should proxy this transparently; that is, the applications Dog invokes should transparently know if they're writing to a TTY.

The easiest way to do this is probably to pass os.Stdout as their Stdout when invoking them.

@xsb xsb reopened this Jan 21, 2017
@xsb xsb changed the title Strips colors Dog strips colors of task output Feb 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants