The following commit has been merged in the master branch:
commit a7df7bc856fd3add35ba44f7bd23901913a539d4
Author: Guillem Jover <[email protected]>
Date:   Thu Nov 4 19:13:59 2010 +0100

    dpkg: Use command_shell() instead of ad-hoc code to execute shells

diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index 277558b..b7f1558 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -42,6 +42,7 @@
 #include <dpkg/dpkg.h>
 #include <dpkg/buffer.h>
 #include <dpkg/subproc.h>
+#include <dpkg/command.h>
 #include <dpkg/compress.h>
 #include <dpkg/ar.h>
 #include <dpkg/myopt.h>
@@ -55,9 +56,7 @@ static void movecontrolfiles(const char *thing) {
   sprintf(buf, "mv %s/* . && rmdir %s", thing, thing);
   c1 = subproc_fork();
   if (!c1) {
-    execlp("sh", "sh", "-c", buf, NULL);
-    ohshite(_("unable to execute %s (%s)"),
-            _("shell command to move files"), buf);
+    command_shell(buf, _("shell command to move files"));
   }
   subproc_wait_check(c1, _("shell command to move files"), 0);
 }
diff --git a/src/configure.c b/src/configure.c
index 441d1bf..55d56b3 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -45,6 +45,7 @@
 #include <dpkg/buffer.h>
 #include <dpkg/file.h>
 #include <dpkg/subproc.h>
+#include <dpkg/command.h>
 #include <dpkg/triglib.h>
 
 #include "filesdb.h"
@@ -502,7 +503,6 @@ showdiff(const char *old, const char *new)
        if (!pid) {
                /* Child process. */
                const char *pager;
-               const char *shell;
                char cmdbuf[1024];
 
                pager = getenv(PAGERENV);
@@ -512,13 +512,7 @@ showdiff(const char *old, const char *new)
                sprintf(cmdbuf, DIFF " -Nu %.250s %.250s | %.250s",
                        old, new, pager);
 
-               shell = getenv(SHELLENV);
-               if (!shell || !*shell)
-                       shell = DEFAULTSHELL;
-
-               execlp(shell, shell, "-c", cmdbuf, NULL);
-               ohshite(_("unable to execute %s (%s)"),
-                       _("conffile difference visualizer"), cmdbuf);
+               command_shell(cmdbuf, _("conffile difference visualizer"));
        }
 
        /* Parent process. */
@@ -543,21 +537,12 @@ spawn_shell(const char *confold, const char *confnew)
 
        pid = subproc_fork();
        if (!pid) {
-               /* Child process */
-               const char *shell;
-
-               shell = getenv(SHELLENV);
-               if (!shell || !*shell)
-                       shell = DEFAULTSHELL;
-
                /* Set useful variables for the user. */
                setenv("DPKG_SHELL_REASON", "conffile-prompt", 1);
                setenv("DPKG_CONFFILE_OLD", confold, 1);
                setenv("DPKG_CONFFILE_NEW", confnew, 1);
 
-               execlp(shell, shell, "-i", NULL);
-               ohshite(_("unable to execute %s (%s)"),
-                       _("conffile shell"), shell);
+               command_shell(NULL, _("conffile shell"));
        }
 
        /* Parent process. */

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to