git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Date
Dec 1, 2017, 03:26 UTC
Message-ID
<a9786a9f-66c9-9f1e-75c8-b2c5a81b08aa@gmail.com>
In-Reply-To
<20171129143752.60553-2-lars.schneider@autodesk.com>
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'.

Show 32 quoted lines
> +}
> +
>   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

Previous: Jeff KingNext: lars.schneider@autodesk.com
Message 4 of 31 in “launch_editor(): indicate that Git waits for user input”
  1. 0/2 launch_editor(): indicate that Git waits for user inputlars.schneider@autodesk.com, Nov 29, 2017
  2. 1/2 refactor "dumb" terminal determinationlars.schneider@autodesk.com, Nov 29, 2017
  3. Jeff KingNov 30, 2017
  4. Kaartic SivaraamDec 1, 2017
  5. 2/2 launch_editor(): indicate that Git waits for user inputlars.schneider@autodesk.com, Nov 29, 2017
  6. Jeff KingNov 30, 2017
  7. Kaartic SivaraamDec 1, 2017
  8. Lars SchneiderDec 1, 2017
  9. Jeff KingDec 1, 2017
  10. Kaartic SivaraamDec 2, 2017
  11. Lars SchneiderDec 3, 2017
  12. Kaartic SivaraamDec 4, 2017
  13. Jeff KingDec 4, 2017
  14. Lars SchneiderDec 4, 2017
  15. Jeff KingDec 4, 2017
  16. Lars SchneiderDec 4, 2017
  17. Jeff KingDec 4, 2017
  18. Jeff KingDec 4, 2017
  19. Junio C HamanoDec 3, 2017
  20. Lars SchneiderDec 3, 2017
  21. Jeff KingDec 4, 2017
  22. Lars SchneiderDec 4, 2017
  23. Junio C HamanoDec 4, 2017
  24. Jeff KingDec 4, 2017
  25. Thomas AdamNov 29, 2017
  26. Lars SchneiderNov 30, 2017
  27. Thomas AdamNov 30, 2017
  28. Andreas SchwabNov 30, 2017
  29. Kaartic SivaraamDec 1, 2017
  30. Jeff KingNov 30, 2017
  31. Thomas AdamNov 30, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.