Thread (23 messages) flat view 23 messages, 5 authors, 2017-12-04

Re: [PATCH v4 1/2] refactor "dumb" terminal determination

From: Kaartic Sivaraam <hidden>
Date: 2017-12-01 03:26:55

On Wednesday 29 November 2017 08:07 PM, lars.schneider@autodesk.com wrote:
+int is_terminal_dumb(void)
+{
+	const char *terminal = getenv("TERM");
+	return !terminal || !strcmp(terminal, "dumb");
So, IIUC, there terminal is considered to be 'dumb' when the TERM 
environment variable is NOT set or when it is set to 'dumb'.
quoted hunk ↗ jump to hunk
+}
+
  const char *git_editor(void)
  {
  	const char *editor = getenv("GIT_EDITOR");
-	const char *terminal = getenv("TERM");
-	int terminal_is_dumb = !terminal || !strcmp(terminal, "dumb");
+	int terminal_is_dumb = is_terminal_dumb();
  
  	if (!editor && editor_program)
  		editor = editor_program;
diff --git a/sideband.c b/sideband.c
index 1e4d684d6c..6d7f943e43 100644
--- a/sideband.c
+++ b/sideband.c
@@ -20,13 +20,12 @@
  
  int recv_sideband(const char *me, int in_stream, int out)
  {
-	const char *term, *suffix;
+	const char *suffix;
  	char buf[LARGE_PACKET_MAX + 1];
  	struct strbuf outbuf = STRBUF_INIT;
  	int retval = 0;
  
-	term = getenv("TERM");
-	if (isatty(2) && term && strcmp(term, "dumb"))
+	if (isatty(2) && !is_terminal_dumb())
  		suffix = ANSI_SUFFIX;
  	else
  		suffix = DUMB_SUFFIX;
This one looks good to me if my observation above is correct.

---
Kaartic
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help