+static void
+breakup_args (char *scratch, char **argv)
+{
+ char *cp = scratch, *tmp;
+
+ for (;;)
+ {
+ /* Scan past leading separators */
+ while (*cp == ' ' || *cp == '\t' || *cp == '\n')
+ cp++;
+
+ /* Break if at end of string. */
+ if (*cp == '\0')
+ break;
+
+ /* Take an arg. */
+ *argv++ = cp;
+
+ /* Scan for next arg separator. */
+ tmp = strchr (cp, ' ');
+ if (tmp == NULL)
+ tmp = strchr (cp, '\t');
+ if (tmp == NULL)
+ tmp = strchr (cp, '\n');
+
+ /* No separators => end of string => break. */
+ if (tmp == NULL)
+ break;
+ cp = tmp;
+
+ /* Replace the separator with a terminator. */
+ *cp++ = '\0';
+ }
+
+ /* Null-terminate the vector. */
+ *argv = NULL;
+}
+
+/* When executing a command under the given shell, return non-zero if
+ the '!' character should be escaped when embedded in a quoted
+ command-line argument. */
+
+static int
+escape_bang_in_quoted_argument (const char *shell_file)
+{
+ const int shell_file_len = strlen (shell_file);
+
+ /* Bang should be escaped only in C Shells. For now, simply check
+ that the shell name ends with 'csh', which covers at least csh
+ and tcsh. This should be good enough for now. */
+
+ if (shell_file_len < 3)
+ return 0;
+
+ if (shell_file[shell_file_len - 3] == 'c'
+ && shell_file[shell_file_len - 2] == 's'
+ && shell_file[shell_file_len - 1] == 'h')
+ return 1;
+
+ return 0;
+}
+
+/* Start an inferior Unix child process and sets inferior_ptid to its
+ pid. EXEC_FILE is the file to run. ALLARGS is a string containing
+ the arguments to the program. ENV is the environment vector to
+ pass. SHELL_FILE is the shell file, or NULL if we should pick
+ one. */
+
+/* This function is NOT reentrant. Some of the variables have been
+ made static to ensure that they survive the vfork call. */
+
+int
+fork_inferior (char *exec_file_arg, char *allargs, char **env,
+ void (*traceme_fun) (void), void (*init_trace_fun) (int),
+ void (*pre_trace_fun) (void), char *shell_file_arg)