version 1.21, 2005/05/15 16:22:12 |
version 1.22, 2005/11/14 15:30:54 |
|
|
* the end to consume (nargs) arguments each time round the loop. |
* the end to consume (nargs) arguments each time round the loop. |
* Allocate enough space to hold the maximum command. |
* Allocate enough space to hold the maximum command. |
*/ |
*/ |
len = sizeof("exec ") - 1 + |
|
strlen(argv[0]) + 9 * (sizeof(" %1") - 1) + 1; |
|
if ((cmd = malloc(len)) == NULL) |
|
err(1, NULL); |
|
|
|
if (n == 0) { |
if (n == 0) { |
int l; |
int l; |
|
|
|
len = sizeof("exec ") - 1 + |
|
strlen(argv[0]) + 9 * (sizeof(" %1") - 1) + 1; |
|
if ((cmd = malloc(len)) == NULL) |
|
err(1, NULL); |
|
|
/* If nargs not set, default to a single argument. */ |
/* If nargs not set, default to a single argument. */ |
if (nargs == -1) |
if (nargs == -1) |
nargs = 1; |
nargs = 1; |
|
|
if (nargs == 0) |
if (nargs == 0) |
nargs = 1; |
nargs = 1; |
} else { |
} else { |
(void)snprintf(cmd, len, "exec %s", argv[0]); |
if (asprintf(&cmd, "exec %s", argv[0]) == -1) |
|
err(1, NULL); |
nargs = n; |
nargs = n; |
} |
} |
|
|