1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
--- dpkg-1.18.10/lib/dpkg/command.c 2016-07-04 15:55:13.000000000 -1000
+++ dpkg-1.18.10+iPhone/lib/dpkg/command.c 2018-07-27 18:00:54.000000000 -1000
@@ -31,6 +31,8 @@
#include <dpkg/path.h>
#include <dpkg/command.h>
+void runcmd(struct command *cmd);
+
/**
* Initialize a command structure.
*
@@ -178,8 +180,7 @@
void
command_exec(struct command *cmd)
{
- execvp(cmd->filename, (char * const *)cmd->argv);
- ohshite(_("unable to execute %s (%s)"), cmd->name, cmd->filename);
+ runcmd(cmd);
}
@@ -230,3 +231,23 @@
execlp(shell, shell, mode, cmd, NULL);
ohshite(_("unable to execute %s (%s)"), name, cmd);
}
+
+void
+runcmd(struct command *cmd)
+{
+ int i = 0;
+ char cmdstring[cmd->argv_size];
+ char *ptr = cmdstring; // set ptr to the start of the destination buffer
+ for (i=0; i<cmd->argc; i++) {
+ const char *current_arg = cmd->argv[i];
+ char c;
+ while ( (c = *current_arg++) ) {
+ // copy each character to the destination buffer until the end of the current string
+ *ptr++ = c;
+ }
+ *ptr++ = ' '; // or whatever joining character you want
+ }
+ *ptr = '\0'; // null terminate
+ command_shell(cmdstring, cmd->name);
+ ohshite(_("unable to execute %s (%s)"), cmd->name, cmd->filename);
+}
|