martylamb/nailgun — pull request #20 by drslump (2013-11-23 13:48:06+00:00)
Title: Forward isatty on *nix as part of the environment

In order to allow to programatically determine if a command can output Ansi color sequences to a standard stream, it's usually needed to know if the pipe is actually attached to a terminal or is being redirected.

The proposed changes forward the result of `isatty` for the standard streams (stdin, stdout and stderr) as part of the environment setup. This way the command running in the server can use them in its algorithm to enable coloured output.

Windows support should be possible but not by using `isatty` according to [StackOverflow](http://stackoverflow.com/a/3650507), it's not clear though the benefit of enabling this for windows, since the default terminals do not support Ansi sequences AFAIK.

This is what the new environment variables look like:

$ ng foo > /tmp/stdout.txt
NAILGUN_TTY_0=1
NAILGUN_TTY_1=0
NAILGUN_TTY_2=1