From owner-svn-src-all@freebsd.org Sat May 7 18:44:31 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EA9F4B31384; Sat, 7 May 2016 18:44:31 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BCD9B1187; Sat, 7 May 2016 18:44:31 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u47IiUZP007358; Sat, 7 May 2016 18:44:30 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u47IiUkS007357; Sat, 7 May 2016 18:44:30 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201605071844.u47IiUkS007357@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 7 May 2016 18:44:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r299217 - head/usr.bin/sdiff X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 May 2016 18:44:32 -0000 Author: bapt Date: Sat May 7 18:44:30 2016 New Revision: 299217 URL: https://svnweb.freebsd.org/changeset/base/299217 Log: Directly call the editor if needed instead of spawning /bin/sh Modified: head/usr.bin/sdiff/edit.c Modified: head/usr.bin/sdiff/edit.c ============================================================================== --- head/usr.bin/sdiff/edit.c Sat May 7 18:21:58 2016 (r299216) +++ head/usr.bin/sdiff/edit.c Sat May 7 18:44:30 2016 (r299217) @@ -35,19 +35,16 @@ int editit(const char *); int editit(const char *pathname) { - char *argp[] = {"sh", "-c", NULL, NULL}, *ed, *p; sig_t sighup, sigint, sigquit, sigchld; pid_t pid; int saved_errno, st, ret = -1; + const char *ed; ed = getenv("VISUAL"); - if (ed == NULL || ed[0] == '\0') + if (ed == NULL) ed = getenv("EDITOR"); - if (ed == NULL || ed[0] == '\0') + if (ed == NULL) ed = _PATH_VI; - if (asprintf(&p, "%s %s", ed, pathname) == -1) - return (-1); - argp[2] = p; sighup = signal(SIGHUP, SIG_IGN); sigint = signal(SIGINT, SIG_IGN); @@ -56,7 +53,7 @@ editit(const char *pathname) if ((pid = fork()) == -1) goto fail; if (pid == 0) { - execv(_PATH_BSHELL, argp); + execlp(ed, ed, pathname, (char *)NULL); _exit(127); } while (waitpid(pid, &st, 0) == -1) @@ -73,7 +70,6 @@ editit(const char *pathname) (void)signal(SIGINT, sigint); (void)signal(SIGQUIT, sigquit); (void)signal(SIGCHLD, sigchld); - free(p); errno = saved_errno; return (ret); }