From a64f213d3fa13fa01e582b6734fe7883ed975dc9 Mon Sep 17 00:00:00 2001 From: Lars Schneider Date: Wed, 29 Nov 2017 15:37:51 +0100 Subject: refactor "dumb" terminal determination Move the code to detect "dumb" terminals into a single location. This avoids duplicating the terminal detection code yet again in a subsequent commit. Signed-off-by: Lars Schneider Signed-off-by: Junio C Hamano --- editor.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'editor.c') diff --git a/editor.c b/editor.c index 7519edecdc..c65ea698eb 100644 --- a/editor.c +++ b/editor.c @@ -7,11 +7,16 @@ #define DEFAULT_EDITOR "vi" #endif +int is_terminal_dumb(void) +{ + const char *terminal = getenv("TERM"); + return !terminal || !strcmp(terminal, "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; -- cgit v1.2.3