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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 29 November 2017 08:07 PM, lars.schneider@xxxxxxxxxxxx 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'.

+}
+
  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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux