aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2017-07-07 23:06:07 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-07-10 09:16:52 +0200
commit458990b0c155130e242117e2bfc5ebfdf787d2e2 (patch)
treeaedf2eca9a95afcf30812dd5d7108765adf85afd /src/main/java/com
parenta9f7687e6d4b8ef58766c6c1c85e38ed0993cd4a (diff)
Look at stderr for terminal detection.
bazel prints all the progress to stderr, yet the decision to switch between "smart" and "dumb" output modes is done based on the stdout and stderr connected terminals. That breaks for a command like this: bazel query 'something' | wc -l Even though all the progress is still output to the terminal through stderr, bazel switches to "dumb" mode, printing progress messages one per line. It seems reasonable to make the "smart"/"dumb" output mode decision based on the stderr only. Tested: With the change "bazel query '...' | wc -l" prints "smart" progress messages. RELNOTES: Check stderr to detect if connected to a terminal. Deprecate --isatty. PiperOrigin-RevId: 161243017
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java
index 187aa12e23..cd2f1fd279 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java
@@ -96,7 +96,7 @@ public class BlazeCommandEventHandler implements EventHandler {
category = "verbosity",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
- help = "Use terminal controls to colorize output."
+ help = "Use terminal controls to colorize output going to stderr."
)
public UseColor useColorEnum;
@@ -107,7 +107,7 @@ public class BlazeCommandEventHandler implements EventHandler {
category = "verbosity",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
- help = "Use terminal cursor controls to minimize scrolling output"
+ help = "Use terminal cursor controls to minimize scrolling output going to stderr."
)
public UseCurses useCursesEnum;
@@ -122,18 +122,21 @@ public class BlazeCommandEventHandler implements EventHandler {
public int terminalColumns;
@Option(
- name = "isatty",
+ name = "is_stderr_atty",
+ // TODO(laszlocsomor): Old name should be removed after 2017-12-28.
+ oldName = "isatty",
defaultValue = "false",
optionUsageRestrictions = OptionUsageRestrictions.HIDDEN,
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
help =
- "A system-generated parameter which is used to notify the "
- + "server whether this client is running in a terminal. "
- + "If this is set to false, then '--color=auto' will be treated as '--color=no'. "
- + "If this is set to true, then '--color=auto' will be treated as '--color=yes'."
+ "A system-generated parameter which is used to notify the server whether this client is"
+ + " running in a terminal. If this is set to false, then '--color=auto' will be"
+ + " treated as '--color=no'. If this is set to true, then '--color=auto' will be"
+ + " treated as '--color=yes'. As we only treat the stderr as a terminal, we only"
+ + " care that file descriptor is connected to a TTY."
)
- public boolean isATty;
+ public boolean isStderrATty;
// This lives here (as opposed to the more logical BuildRequest.Options)
// because the client passes it to the server *always*. We don't want the
@@ -244,11 +247,11 @@ public class BlazeCommandEventHandler implements EventHandler {
public int experimentalUiLimitConsoleOutput;
public boolean useColor() {
- return useColorEnum == UseColor.YES || (useColorEnum == UseColor.AUTO && isATty);
+ return useColorEnum == UseColor.YES || (useColorEnum == UseColor.AUTO && isStderrATty);
}
public boolean useCursorControl() {
- return useCursesEnum == UseCurses.YES || (useCursesEnum == UseCurses.AUTO && isATty);
+ return useCursesEnum == UseCurses.YES || (useCursesEnum == UseCurses.AUTO && isStderrATty);
}
}