]> diplodocus.org Git - nmh/blob - sbr/geteditor.c
693d2d777309404e862ae56514d0f36a75c053db
[nmh] / sbr / geteditor.c
1 /* geteditor.c -- Determine the default editor to use
2 *
3 * This code is Copyright (c) 2013, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
6 */
7
8 #include "h/mh.h"
9 #include "context_find.h"
10 #include "h/utils.h"
11
12 static char *default_editor = NULL;
13
14 char *
15 get_default_editor(void)
16 {
17 char *str;
18
19 if (default_editor)
20 return default_editor;
21
22 if (!(str = context_find("editor")) && !(str = getenv("VISUAL")) &&
23 !(str = getenv("EDITOR"))) {
24 str = "vi";
25 }
26
27 return default_editor = str;
28 }