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