~mcepl/ldapvi

048068e82bd86bdcdb637ea95f1ad968f28bc5f9 — Anders Kaseorg 13 years ago 33d2368
Handle editor commands with arguments

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>
1 files changed, 4 insertions(+), 2 deletions(-)

M ldapvi/misc.c
M ldapvi/misc.c => ldapvi/misc.c +4 -2
@@ 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, (char *) NULL);
			execl("/bin/sh", "sh", "-c", "exec $0 \"$@\"", vi,
			      buf, pathname, (char *) NULL);
		} else
			execlp(vi, vi, pathname, (char *) NULL);
			execl("/bin/sh", "sh", "-c", "exec $0 \"$@\"", vi,
			      pathname, (char *) NULL);
		syserr();
	}