| 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 |
#include <windows.h> |
|---|
| 34 |
|
|---|
| 35 |
#include <stdarg.h> |
|---|
| 36 |
#include <malloc.h> |
|---|
| 37 |
#include <stdlib.h> |
|---|
| 38 |
#include <string.h> |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
#ifdef MEADOW |
|---|
| 42 |
|
|---|
| 43 |
#if _MSC_VER >= 1300 |
|---|
| 44 |
#define stricmp _stricmp |
|---|
| 45 |
#define strdup _strdup |
|---|
| 46 |
#endif |
|---|
| 47 |
#endif |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
#define stdin GetStdHandle (STD_INPUT_HANDLE) |
|---|
| 54 |
#define stdout GetStdHandle (STD_OUTPUT_HANDLE) |
|---|
| 55 |
#define stderr GetStdHandle (STD_ERROR_HANDLE) |
|---|
| 56 |
|
|---|
| 57 |
int |
|---|
| 58 |
vfprintf(HANDLE hnd, char * msg, va_list args) |
|---|
| 59 |
{ |
|---|
| 60 |
DWORD bytes_written; |
|---|
| 61 |
char buf[1024]; |
|---|
| 62 |
|
|---|
| 63 |
wvsprintf (buf, msg, args); |
|---|
| 64 |
return WriteFile (hnd, buf, strlen (buf), &bytes_written, NULL); |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
int |
|---|
| 68 |
fprintf(HANDLE hnd, char * msg, ...) |
|---|
| 69 |
{ |
|---|
| 70 |
va_list args; |
|---|
| 71 |
int rc; |
|---|
| 72 |
|
|---|
| 73 |
va_start (args, msg); |
|---|
| 74 |
rc = vfprintf (hnd, msg, args); |
|---|
| 75 |
va_end (args); |
|---|
| 76 |
|
|---|
| 77 |
return rc; |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
int |
|---|
| 81 |
printf(char * msg, ...) |
|---|
| 82 |
{ |
|---|
| 83 |
va_list args; |
|---|
| 84 |
int rc; |
|---|
| 85 |
|
|---|
| 86 |
va_start (args, msg); |
|---|
| 87 |
rc = vfprintf (stdout, msg, args); |
|---|
| 88 |
va_end (args); |
|---|
| 89 |
|
|---|
| 90 |
return rc; |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
void |
|---|
| 94 |
fail (char * msg, ...) |
|---|
| 95 |
{ |
|---|
| 96 |
va_list args; |
|---|
| 97 |
|
|---|
| 98 |
va_start (args, msg); |
|---|
| 99 |
vfprintf (stderr, msg, args); |
|---|
| 100 |
va_end (args); |
|---|
| 101 |
|
|---|
| 102 |
exit (-1); |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
void |
|---|
| 106 |
warn (char * msg, ...) |
|---|
| 107 |
{ |
|---|
| 108 |
va_list args; |
|---|
| 109 |
|
|---|
| 110 |
va_start (args, msg); |
|---|
| 111 |
vfprintf (stderr, msg, args); |
|---|
| 112 |
va_end (args); |
|---|
| 113 |
} |
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
char * |
|---|
| 118 |
canon_filename (char *fname) |
|---|
| 119 |
{ |
|---|
| 120 |
char *p = fname; |
|---|
| 121 |
|
|---|
| 122 |
while (*p) |
|---|
| 123 |
{ |
|---|
| 124 |
if (*p == '/') |
|---|
| 125 |
*p = '\\'; |
|---|
| 126 |
p++; |
|---|
| 127 |
} |
|---|
| 128 |
|
|---|
| 129 |
return fname; |
|---|
| 130 |
} |
|---|
| 131 |
|
|---|
| 132 |
char * |
|---|
| 133 |
skip_space (char *str) |
|---|
| 134 |
{ |
|---|
| 135 |
while (isspace (*str)) str++; |
|---|
| 136 |
return str; |
|---|
| 137 |
} |
|---|
| 138 |
|
|---|
| 139 |
char * |
|---|
| 140 |
skip_nonspace (char *str) |
|---|
| 141 |
{ |
|---|
| 142 |
while (*str && !isspace (*str)) str++; |
|---|
| 143 |
return str; |
|---|
| 144 |
} |
|---|
| 145 |
|
|---|
| 146 |
int escape_char = '\\'; |
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
int |
|---|
| 150 |
get_next_token (char * buf, char ** pSrc) |
|---|
| 151 |
{ |
|---|
| 152 |
char * p = *pSrc; |
|---|
| 153 |
char * o = buf; |
|---|
| 154 |
|
|---|
| 155 |
p = skip_space (p); |
|---|
| 156 |
if (*p == '"') |
|---|
| 157 |
{ |
|---|
| 158 |
int escape_char_run = 0; |
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
p++; |
|---|
| 165 |
while (1) |
|---|
| 166 |
{ |
|---|
| 167 |
if (p[0] == escape_char && escape_char != '"') |
|---|
| 168 |
{ |
|---|
| 169 |
escape_char_run++; |
|---|
| 170 |
p++; |
|---|
| 171 |
continue; |
|---|
| 172 |
} |
|---|
| 173 |
else if (p[0] == '"') |
|---|
| 174 |
{ |
|---|
| 175 |
while (escape_char_run > 1) |
|---|
| 176 |
{ |
|---|
| 177 |
*o++ = escape_char; |
|---|
| 178 |
escape_char_run -= 2; |
|---|
| 179 |
} |
|---|
| 180 |
|
|---|
| 181 |
if (escape_char_run > 0) |
|---|
| 182 |
{ |
|---|
| 183 |
|
|---|
| 184 |
*o++ = *p++; |
|---|
| 185 |
escape_char_run = 0; |
|---|
| 186 |
} |
|---|
| 187 |
else if (p[1] == escape_char && escape_char == '"') |
|---|
| 188 |
{ |
|---|
| 189 |
|
|---|
| 190 |
*o++ = *p; |
|---|
| 191 |
p += 2; |
|---|
| 192 |
} |
|---|
| 193 |
else |
|---|
| 194 |
{ |
|---|
| 195 |
|
|---|
| 196 |
*o = '\0'; |
|---|
| 197 |
|
|---|
| 198 |
p++; |
|---|
| 199 |
break; |
|---|
| 200 |
} |
|---|
| 201 |
} |
|---|
| 202 |
else if (p[0] == '\0') |
|---|
| 203 |
{ |
|---|
| 204 |
|
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
*o = '\0'; |
|---|
| 208 |
break; |
|---|
| 209 |
} |
|---|
| 210 |
else |
|---|
| 211 |
{ |
|---|
| 212 |
*o++ = *p++; |
|---|
| 213 |
} |
|---|
| 214 |
} |
|---|
| 215 |
} |
|---|
| 216 |
else |
|---|
| 217 |
{ |
|---|
| 218 |
|
|---|
| 219 |
char * p1 = skip_nonspace (p); |
|---|
| 220 |
memcpy (o, p, p1 - p); |
|---|
| 221 |
o += (p1 - p); |
|---|
| 222 |
*o = '\0'; |
|---|
| 223 |
p = p1; |
|---|
| 224 |
} |
|---|
| 225 |
|
|---|
| 226 |
*pSrc = p; |
|---|
| 227 |
|
|---|
| 228 |
return o - buf; |
|---|
| 229 |
} |
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 |
|
|---|
| 233 |
int |
|---|
| 234 |
search_dir (char *dir, char *exec, int bufsize, char *buffer) |
|---|
| 235 |
{ |
|---|
| 236 |
char *exts[] = {".bat", ".cmd", ".exe", ".com"}; |
|---|
| 237 |
int n_exts = sizeof (exts) / sizeof (char *); |
|---|
| 238 |
char *dummy; |
|---|
| 239 |
int i, rc; |
|---|
| 240 |
|
|---|
| 241 |
|
|---|
| 242 |
for (i = 0; i < n_exts; i++) |
|---|
| 243 |
{ |
|---|
| 244 |
rc = SearchPath (dir, exec, exts[i], bufsize, buffer, &dummy); |
|---|
| 245 |
if (rc > 0) |
|---|
| 246 |
return rc; |
|---|
| 247 |
} |
|---|
| 248 |
|
|---|
| 249 |
return 0; |
|---|
| 250 |
} |
|---|
| 251 |
|
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
char * |
|---|
| 256 |
make_absolute (char *prog) |
|---|
| 257 |
{ |
|---|
| 258 |
char absname[MAX_PATH]; |
|---|
| 259 |
char dir[MAX_PATH]; |
|---|
| 260 |
char curdir[MAX_PATH]; |
|---|
| 261 |
char *p, *fname; |
|---|
| 262 |
char *path; |
|---|
| 263 |
int i; |
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 |
if ((isalpha (prog[0]) && prog[1] == ':') || |
|---|
| 267 |
(prog[0] == '\\')) |
|---|
| 268 |
{ |
|---|
| 269 |
|
|---|
| 270 |
fname = strrchr (prog, '\\'); |
|---|
| 271 |
if (!fname) |
|---|
| 272 |
|
|---|
| 273 |
fname = prog + 2; |
|---|
| 274 |
strncpy (dir, prog, fname - prog); |
|---|
| 275 |
dir[fname - prog] = '\0'; |
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
if (search_dir (dir, prog, MAX_PATH, absname) > 0) |
|---|
| 279 |
return strdup (absname); |
|---|
| 280 |
else |
|---|
| 281 |
return NULL; |
|---|
| 282 |
} |
|---|
| 283 |
|
|---|
| 284 |
if (GetCurrentDirectory (MAX_PATH, curdir) <= 0) |
|---|
| 285 |
return NULL; |
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
if (strpbrk (prog, "\\")) |
|---|
| 289 |
{ |
|---|
| 290 |
if (search_dir (curdir, prog, MAX_PATH, absname) > 0) |
|---|
| 291 |
return strdup (absname); |
|---|
| 292 |
else |
|---|
| 293 |
return NULL; |
|---|
| 294 |
} |
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 |
path = alloca (strlen (getenv ("PATH")) + strlen (curdir) + 2); |
|---|
| 298 |
strcpy (path, curdir); |
|---|
| 299 |
strcat (path, ";"); |
|---|
| 300 |
strcat (path, getenv ("PATH")); |
|---|
| 301 |
|
|---|
| 302 |
while (*path) |
|---|
| 303 |
{ |
|---|
| 304 |
|
|---|
| 305 |
p = path; |
|---|
| 306 |
while (*p && *p != ';') p++; |
|---|
| 307 |
strncpy (dir, path, p - path); |
|---|
| 308 |
dir[p - path] = '\0'; |
|---|
| 309 |
|
|---|
| 310 |
|
|---|
| 311 |
if (search_dir (dir, prog, MAX_PATH, absname) > 0) |
|---|
| 312 |
return strdup (absname); |
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
path = p + 1; |
|---|
| 316 |
} |
|---|
| 317 |
|
|---|
| 318 |
return NULL; |
|---|
| 319 |
} |
|---|
| 320 |
|
|---|
| 321 |
|
|---|
| 322 |
|
|---|
| 323 |
#if 0 |
|---|
| 324 |
char ** _argv; |
|---|
| 325 |
int _argc; |
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 |
void |
|---|
| 329 |
setup_argv (void) |
|---|
| 330 |
{ |
|---|
| 331 |
char * cmdline = GetCommandLine (); |
|---|
| 332 |
int arg_bytes = 0; |
|---|
| 333 |
|
|---|
| 334 |
|
|---|
| 335 |
} |
|---|
| 336 |
#endif |
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 |
PROCESS_INFORMATION child; |
|---|
| 343 |
int interactive = TRUE; |
|---|
| 344 |
|
|---|
| 345 |
BOOL |
|---|
| 346 |
console_event_handler (DWORD event) |
|---|
| 347 |
{ |
|---|
| 348 |
switch (event) |
|---|
| 349 |
{ |
|---|
| 350 |
case CTRL_C_EVENT: |
|---|
| 351 |
case CTRL_BREAK_EVENT: |
|---|
| 352 |
if (!interactive) |
|---|
| 353 |
{ |
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
|
|---|
| 357 |
|
|---|
| 358 |
|
|---|
| 359 |
|
|---|
| 360 |
if (child.hProcess && |
|---|
| 361 |
WaitForSingleObject (child.hProcess, 500) != WAIT_OBJECT_0) |
|---|
| 362 |
TerminateProcess (child.hProcess, 0); |
|---|
| 363 |
exit (STATUS_CONTROL_C_EXIT); |
|---|
| 364 |
} |
|---|
| 365 |
break; |
|---|
| 366 |
|
|---|
| 367 |
#if 0 |
|---|
| 368 |
default: |
|---|
| 369 |
|
|---|
| 370 |
|
|---|
| 371 |
fail ("cmdproxy: received %d event\n", event); |
|---|
| 372 |
if (child.hProcess) |
|---|
| 373 |
TerminateProcess (child.hProcess, 0); |
|---|
| 374 |
#endif |
|---|
| 375 |
} |
|---|
| 376 |
return TRUE; |
|---|
| 377 |
} |
|---|
| 378 |
|
|---|
| 379 |
|
|---|
| 380 |
|
|---|
| 381 |
int |
|---|
| 382 |
spawn (char * progname, char * cmdline, char * dir, int * retcode) |
|---|
| 383 |
{ |
|---|
| 384 |
BOOL success = FALSE; |
|---|
| 385 |
SECURITY_ATTRIBUTES sec_attrs; |
|---|
| 386 |
STARTUPINFO start; |
|---|
| 387 |
|
|---|
| 388 |
|
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 |
char * envblock = GetEnvironmentStrings (); |
|---|
| 392 |
|
|---|
| 393 |
sec_attrs.nLength = sizeof (sec_attrs); |
|---|
| 394 |
sec_attrs.lpSecurityDescriptor = NULL; |
|---|
| 395 |
sec_attrs.bInheritHandle = FALSE; |
|---|
| 396 |
|
|---|
| 397 |
memset (&start, 0, sizeof (start)); |
|---|
| 398 |
start.cb = sizeof (start); |
|---|
| 399 |
|
|---|
| 400 |
if (CreateProcess (progname, cmdline, &sec_attrs, NULL, TRUE, |
|---|
| 401 |
0, envblock, dir, &start, &child)) |
|---|
| 402 |
{ |
|---|
| 403 |
success = TRUE; |
|---|
| 404 |
|
|---|
| 405 |
WaitForSingleObject (child.hProcess, INFINITE); |
|---|
| 406 |
if (retcode) |
|---|
| 407 |
GetExitCodeProcess (child.hProcess, (DWORD *)retcode); |
|---|
| 408 |
CloseHandle (child.hThread); |
|---|
| 409 |
CloseHandle (child.hProcess); |
|---|
| 410 |
child.hProcess = NULL; |
|---|
| 411 |
} |
|---|
| 412 |
|
|---|
| 413 |
FreeEnvironmentStrings (envblock); |
|---|
| 414 |
|
|---|
| 415 |
return success; |
|---|
| 416 |
} |
|---|
| 417 |
|
|---|
| 418 |
|
|---|
| 419 |
int |
|---|
| 420 |
get_env_size () |
|---|
| 421 |
{ |
|---|
| 422 |
char * start = GetEnvironmentStrings (); |
|---|
| 423 |
char * tmp = start; |
|---|
| 424 |
|
|---|
| 425 |
while (tmp[0] || tmp[1]) |
|---|
| 426 |
++tmp; |
|---|
| 427 |
FreeEnvironmentStrings (start); |
|---|
| 428 |
return tmp + 2 - start; |
|---|
| 429 |
} |
|---|
| 430 |
|
|---|
| 431 |
|
|---|
| 432 |
|
|---|
| 433 |
int |
|---|
| 434 |
main (int argc, char ** argv) |
|---|
| 435 |
{ |
|---|
| 436 |
int rc; |
|---|
| 437 |
int need_shell; |
|---|
| 438 |
char * cmdline; |
|---|
| 439 |
char * progname; |
|---|
| 440 |
int envsize; |
|---|
| 441 |
char **pass_through_args; |
|---|
| 442 |
int num_pass_through_args; |
|---|
| 443 |
char modname[MAX_PATH]; |
|---|
| 444 |
char path[MAX_PATH]; |
|---|
| 445 |
char dir[MAX_PATH]; |
|---|
| 446 |
|
|---|
| 447 |
|
|---|
| 448 |
interactive = TRUE; |
|---|
| 449 |
|
|---|
| 450 |
SetConsoleCtrlHandler ((PHANDLER_ROUTINE) console_event_handler, TRUE); |
|---|
| 451 |
|
|---|
| 452 |
if (!GetCurrentDirectory (sizeof (dir), dir)) |
|---|
| 453 |
fail ("error: GetCurrentDirectory failed\n"); |
|---|
| 454 |
|
|---|
| 455 |
|
|---|
| 456 |
|
|---|
| 457 |
|
|---|
| 458 |
|
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 |
|
|---|
| 462 |
|
|---|
| 463 |
|
|---|
| 464 |
|
|---|
| 465 |
|
|---|
| 466 |
|
|---|
| 467 |
if (!GetModuleFileName (NULL, modname, sizeof (modname))) |
|---|
| 468 |
fail ("error: GetModuleFileName failed\n"); |
|---|
| 469 |
|
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 |
progname = strrchr (modname, '\\'); |
|---|
| 473 |
*progname = '\0'; |
|---|
| 474 |
SetCurrentDirectory (modname); |
|---|
| 475 |
*progname = '\\'; |
|---|
| 476 |
|
|---|
| 477 |
|
|---|
| 478 |
|
|---|
| 479 |
|
|---|
| 480 |
SetConsoleCP (GetACP()); |
|---|
| 481 |
SetConsoleOutputCP (GetACP()); |
|---|
| 482 |
|
|---|
| 483 |
|
|---|
| 484 |
|
|---|
| 485 |
|
|---|
| 486 |
|
|---|
| 487 |
GetShortPathName (modname, modname, sizeof (modname)); |
|---|
| 488 |
path[0] = '\0'; |
|---|
| 489 |
if (!SearchPath (NULL, argv[0], ".exe", sizeof (path), path, &progname) |
|---|
| 490 |
|| !GetShortPathName (path, path, sizeof (path)) |
|---|
| 491 |
|| stricmp (modname, path) != 0) |
|---|
| 492 |
{ |
|---|
| 493 |
|
|---|
| 494 |
|
|---|
| 495 |
|
|---|
| 496 |
if (spawn (NULL, GetCommandLine (), dir, &rc)) |
|---|
| 497 |
return rc; |
|---|
| 498 |
fail ("Could not run %s\n", GetCommandLine ()); |
|---|
| 499 |
} |
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 |
|
|---|
| 505 |
|
|---|
| 506 |
|
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 |
|
|---|
| 510 |
|
|---|
| 511 |
progname = NULL; |
|---|
| 512 |
cmdline = NULL; |
|---|
| 513 |
|
|---|
| 514 |
need_shell = TRUE; |
|---|
| 515 |
interactive = TRUE; |
|---|
| 516 |
|
|---|
| 517 |
|
|---|
| 518 |
envsize = get_env_size () + 300; |
|---|
| 519 |
pass_through_args = (char **) alloca (argc * sizeof(char *)); |
|---|
| 520 |
num_pass_through_args = 0; |
|---|
| 521 |
|
|---|
| 522 |
while (--argc > 0) |
|---|
| 523 |
{ |
|---|
| 524 |
++argv; |
|---|
| 525 |
|
|---|
| 526 |
|
|---|
| 527 |
|
|---|
| 528 |
|
|---|
| 529 |
|
|---|
| 530 |
if (((*argv)[0] == '-' || (*argv)[0] == '/') && (*argv)[1] != '\0') |
|---|
| 531 |
{ |
|---|
| 532 |
if (((*argv)[1] == 'c' || (*argv)[1] == 'C') && ((*argv)[2] == '\0')) |
|---|
| 533 |
{ |
|---|
| 534 |
if (--argc == 0) |
|---|
| 535 |
fail ("error: expecting arg for %s\n", *argv); |
|---|
| 536 |
cmdline = *(++argv); |
|---|
| 537 |
interactive = FALSE; |
|---|
| 538 |
} |
|---|
| 539 |
else if (((*argv)[1] == 'i' || (*argv)[1] == 'I') && ((*argv)[2] == '\0')) |
|---|
| 540 |
{ |
|---|
| 541 |
if (cmdline) |
|---|
| 542 |
warn ("warning: %s ignored because of -c\n", *argv); |
|---|
| 543 |
} |
|---|
| 544 |
else if (((*argv)[1] == 'e' || (*argv)[1] == 'E') && ((*argv)[2] == ':')) |
|---|
| 545 |
{ |
|---|
| 546 |
int requested_envsize = atoi (*argv + 3); |
|---|
| 547 |
|
|---|
| 548 |
if (requested_envsize > envsize) |
|---|
| 549 |
envsize = requested_envsize; |
|---|
| 550 |
|
|---|
| 551 |
if (envsize > 32768) |
|---|
| 552 |
envsize = 32768; |
|---|
| 553 |
} |
|---|
| 554 |
else |
|---|
| 555 |
{ |
|---|
| 556 |
|
|---|
| 557 |
pass_through_args[num_pass_through_args++] = *argv; |
|---|
| 558 |
} |
|---|
| 559 |
} |
|---|
| 560 |
else |
|---|
| 561 |
break; |
|---|
| 562 |
} |
|---|
| 563 |
|
|---|
| 564 |
#if 0 |
|---|
| 565 |
|
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 |
|
|---|
| 569 |
|
|---|
| 570 |
while (argc-- > 0) |
|---|
| 571 |
{ |
|---|
| 572 |
pass_through_args[num_pass_through_args++] = *argv++; |
|---|
| 573 |
} |
|---|
| 574 |
#else |
|---|
| 575 |
|
|---|
| 576 |
if (argc > 0) |
|---|
| 577 |
warn ("warning: extra args ignored after '%s'\n", argv[-1]); |
|---|
| 578 |
#endif |
|---|
| 579 |
|
|---|
| 580 |
pass_through_args[num_pass_through_args] = NULL; |
|---|
| 581 |
|
|---|
| 582 |
|
|---|
| 583 |
|
|---|
| 584 |
if (cmdline) |
|---|
| 585 |
{ |
|---|
| 586 |
|
|---|
| 587 |
|
|---|
| 588 |
|
|---|
| 589 |
static char copout_chars[] = "|<>&"; |
|---|
| 590 |
|
|---|
| 591 |
if (strpbrk (cmdline, copout_chars) == NULL) |
|---|
| 592 |
{ |
|---|
| 593 |
char *args; |
|---|
| 594 |
|
|---|
| 595 |
|
|---|
| 596 |
|
|---|
| 597 |
|
|---|
| 598 |
args = cmdline; |
|---|
| 599 |
if (!get_next_token (path, &args)) |
|---|
| 600 |
fail ("error: no program name specified.\n"); |
|---|
| 601 |
|
|---|
| 602 |
canon_filename (path); |
|---|
| 603 |
progname = make_absolute (path); |
|---|
| 604 |
|
|---|
| 605 |
|
|---|
| 606 |
|
|---|
| 607 |
if (progname != NULL) |
|---|
| 608 |
need_shell = FALSE; |
|---|
| 609 |
} |
|---|
| 610 |
} |
|---|
| 611 |
|
|---|
| 612 |
pass_to_shell: |
|---|
| 613 |
if (need_shell) |
|---|
| 614 |
{ |
|---|
| 615 |
char * p; |
|---|
| 616 |
int extra_arg_space = 0; |
|---|
<