Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit Respect $EDITOR when execution one (Baptiste Dar...



details:   https://anonhg.NetBSD.org/src/rev/e27cbc736cfa
branches:  trunk
changeset: 1023178:e27cbc736cfa
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Aug 28 17:17:47 2021 +0000

description:
Respect $EDITOR when execution one (Baptiste Daroussin)

diffstat:

 lib/libedit/vi.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (43 lines):

diff -r ab695d3c85e7 -r e27cbc736cfa lib/libedit/vi.c
--- a/lib/libedit/vi.c  Sat Aug 28 17:11:19 2021 +0000
+++ b/lib/libedit/vi.c  Sat Aug 28 17:17:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vi.c,v 1.63 2019/07/23 10:18:52 christos Exp $ */
+/*     $NetBSD: vi.c,v 1.64 2021/08/28 17:17:47 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)vi.c       8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: vi.c,v 1.63 2019/07/23 10:18:52 christos Exp $");
+__RCSID("$NetBSD: vi.c,v 1.64 2021/08/28 17:17:47 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -1008,12 +1008,15 @@
        char *cp = NULL;
        size_t len;
        wchar_t *line = NULL;
+       const char *editor;
 
        if (el->el_state.doingarg) {
                if (vi_to_history_line(el, 0) == CC_ERROR)
                        return CC_ERROR;
        }
 
+       if ((editor = getenv("EDITOR")) == NULL)
+               editor = "vi";
        fd = mkstemp(tempfile);
        if (fd < 0)
                return CC_ERROR;
@@ -1038,7 +1041,7 @@
                goto error;
        case 0:
                close(fd);
-               execlp("vi", "vi", tempfile, (char *)NULL);
+               execlp(editor, editor, tempfile, (char *)NULL);
                exit(0);
                /*NOTREACHED*/
        default:



Home | Main Index | Thread Index | Old Index