[ldapvi] [PATCH] Handle editor commands with arguments

Anders Kaseorg andersk at MIT.EDU
Tue Dec 14 21:30:13 CET 2010


Previously when the EDITOR environment variable is set to a command
with arguments, such as ‘emacsclient --alternate-editor emacs’, ldapvi
would fail to launch the editor:

$ ldapvi
     26 entries read
error (misc.c line 180): No such file or directory
editor died
error (ldapvi.c line 83): No such file or directory

Fix this by launching the editor via /bin/sh.

Signed-off-by: Anders Kaseorg <andersk at mit.edu>
---
 ldapvi/misc.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/ldapvi/misc.c b/ldapvi/misc.c
index 3b6896e..c50ff0d 100644
--- a/ldapvi/misc.c
+++ b/ldapvi/misc.c
@@ -172,9 +172,11 @@ edit(char *pathname, long line)
 		if (line > 0) {
 			char buf[20];
 			snprintf(buf, 20, "+%ld", line);
-			execlp(vi, vi, buf, pathname, 0);
+			execlp("/bin/sh", "sh", "-c", "exec $0 \"$@\"", vi,
+			       buf, pathname, 0);
 		} else
-			execlp(vi, vi, pathname, 0);
+			execlp("/bin/sh", "sh", "-c", "exec $0 \"$@\"", vi,
+			       pathname, 0);
 		syserr();
 	}
 
-- 
1.7.3.3




More information about the ldapvi mailing list