Process an "-S" string and create the corresponding argv array. Update the given argc/argv parameters with the new argv. Example: if executed as: $ env -S"-i -C/tmp A=B" foo bar The input argv is: argv[0] = "env" argv[1] = "-S-i -C/tmp A=B" argv[2] = "foo" argv[3] = "bar" argv[4] = NULL This function will modify argv to be: argv[0] = "env"
| 523 | argc will be updated from 4 to 6. |
| 524 | optind will be reset to 0 to force getopt_long to rescan all arguments. */ |
| 525 | static void |
| 526 | parse_split_string (char const *str, int *orig_optind, |
| 527 | int *orig_argc, char ***orig_argv) |
| 528 | { |
| 529 | int extra_argc = *orig_argc - *orig_optind, newargc; |
| 530 | char **newargv = build_argv (str, extra_argc, &newargc); |
| 531 | |
| 532 | /* Restore argv[0] - the 'env' executable name. */ |
| 533 | *newargv = (*orig_argv)[0]; |
| 534 | |
| 535 | /* Print parsed arguments. */ |
| 536 | if (dev_debug && 1 < newargc) |
| 537 | { |
| 538 | devmsg ("split -S: %s\n", quote (str)); |
| 539 | devmsg (" into: %s\n", quote (newargv[1])); |
| 540 | for (int i = 2; i < newargc; i++) |
| 541 | devmsg (" & %s\n", quote (newargv[i])); |
| 542 | } |
| 543 | |
| 544 | /* Add remaining arguments and terminating null from the original |
| 545 | command line. */ |
| 546 | memcpy (newargv + newargc, *orig_argv + *orig_optind, |
| 547 | (extra_argc + 1) * sizeof *newargv); |
| 548 | |
| 549 | /* Set new values for original getopt variables. */ |
| 550 | *orig_argc = newargc + extra_argc; |
| 551 | *orig_argv = newargv; |
| 552 | *orig_optind = 0; /* Tell getopt to restart from first argument. */ |
| 553 | } |
| 554 | |
| 555 | static void |
| 556 | parse_signal_action_params (char const *arg, bool set_default) |