Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- text-utils/more.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/text-utils/more.c b/text-utils/more.c index 3e7f5e7..524ce44 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -1342,6 +1342,18 @@ notfound: } } +static char *find_editor(void) +{ + char *editor; + + editor = getenv("VISUAL"); + if (editor == NULL || *editor == '\0') + editor = getenv("EDITOR"); + if (editor == NULL || *editor == '\0') + editor = _PATH_VI; + return editor; +} + static void runtime_usage(void) { fputs( "\n", stdout); @@ -1361,8 +1373,8 @@ static void runtime_usage(void) fputs(_("= Display current line number\n"), stdout); fputs(_("/<regular expression> Search for kth occurrence of regular expression [1]\n"), stdout); fputs(_("n Search for kth occurrence of last r.e [1]\n"), stdout); - fputs(_("!<cmd> or :!<cmd> Execute <cmd> in a subshell\n"), stdout); - fputs(_("v Start up /usr/bin/vi at current line\n"), stdout); + fputs(_("!<cmd> or :!<cmd> Execute <cmd> in a subshell\n"), stdout); fprintf(stdout, _( + "v Start up '%s' at current line\n"), find_editor()); fputs(_("ctrl-L Redraw screen\n"), stdout); fputs(_(":n Go to kth next file [1]\n"), stdout); fputs(_(":p Go to kth previous file [1]\n"), stdout); @@ -1377,11 +1389,7 @@ static void execute_editor(struct more_control *ctl, char *cmdbuf, char *filenam int n = (ctl->Currline - ctl->dlines <= 0 ? 1 : ctl->Currline - (ctl->dlines + 1) / 2); int split = 0; - editor = getenv("VISUAL"); - if (editor == NULL || *editor == '\0') - editor = getenv("EDITOR"); - if (editor == NULL || *editor == '\0') - editor = _PATH_VI; + editor = find_editor(); p = strrchr(editor, '/'); if (p) p++; -- 2.3.0 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html