From 32ca8ca1339eb8152abc76ec7716a4b6747ea3c5 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Thu, 29 Nov 2018 01:21:08 +0530 Subject: [PATCH] Simplify getting editor env var --- src/nnn.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/nnn.c b/src/nnn.c index ec023dfa..f59a453b 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -3577,20 +3577,14 @@ int main(int argc, char *argv[]) /* Edit text in EDITOR, if opted */ if (getenv("NNN_USE_EDITOR")) { - editor = xgetenv("VISUAL", NULL); - if (!editor) - editor = xgetenv("EDITOR", "vi"); - if (editor) { - /* copier used as a temp var */ - copier = editor; - while (*copier) { - if (*copier == ' ') { - *copier = '\0'; - editor_arg = ++copier; - break; - } - ++copier; - } + editor = xgetenv("VISUAL", xgetenv("EDITOR", "vi")); + /* copier used as a temp var */ + copier = editor; + while (*copier && *copier != ' ') + ++copier; + if (*copier == ' ') { + *copier = '\0'; + editor_arg = ++copier; } }