about summary refs log tree commit diff
path: root/src/nix-env/nix-env.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-20T14·01+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-20T14·50+0200
commit373fad75e19a2f24db512621b8cedb627d03d49d (patch)
tree640fd0cac2ccc58f2db5a3f39eba6d0d67badb22 /src/nix-env/nix-env.cc
parent392430b2c4ceb2e476abe2b3acc928581b2a1445 (diff)
Add some color
Diffstat (limited to 'src/nix-env/nix-env.cc')
-rw-r--r--src/nix-env/nix-env.cc10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 44296c7b62ed..ad0f4bdd7105 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -847,13 +847,6 @@ static VersionDiff compareVersionAgainstSet(
 }
 
 
-static string colorString(const string & s)
-{
-    if (!isatty(STDOUT_FILENO)) return s;
-    return "\e[1;31m" + s + "\e[0m";
-}
-
-
 static void queryJSON(Globals & globals, vector<DrvInfo> & elems)
 {
     JSONObject topObj(cout);
@@ -1056,7 +1049,8 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
                     }
                 } else {
                     string column = (string) "" + ch + " " + version;
-                    if (diff == cvGreater) column = colorString(column);
+                    if (diff == cvGreater && isatty(STDOUT_FILENO))
+                        column = ANSI_RED + column + ANSI_NORMAL;
                     columns.push_back(column);
                 }
             }