2004-03-22 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / fork-child.c
index 2ea56a35e9ac96a302c56236cb65c16753aca644..e1d32b064525337fc889952e70752f66b323ff89 100644 (file)
@@ -88,6 +88,29 @@ breakup_args (char *scratch, char **argv)
 
 }
 
+/* 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.
@@ -171,6 +194,7 @@ fork_inferior (char *exec_file_arg, char *allargs, char **env,
 
       char *p;
       int need_to_quote;
+      const int escape_bang = escape_bang_in_quoted_argument (shell_file);
 
       strcat (shell_command, "exec ");
 
@@ -215,7 +239,7 @@ fork_inferior (char *exec_file_arg, char *allargs, char **env,
            {
              if (*p == '\'')
                strcat (shell_command, "'\\''");
-             else if (*p == '!')
+             else if (*p == '!' && escape_bang)
                strcat (shell_command, "\\!");
              else
                strncat (shell_command, p, 1);
@@ -404,13 +428,10 @@ startup_inferior (int ntraps)
   inferior_ignoring_leading_exec_events =
     target_reported_exec_events_per_exec_call () - 1;
 
-#ifdef STARTUP_INFERIOR
-  STARTUP_INFERIOR (pending_execs);
-#else
   while (1)
     {
       /* Make wait_for_inferior be quiet */
-      stop_soon_quietly = STOP_QUIETLY;
+      stop_soon = STOP_QUIETLY;
       wait_for_inferior ();
       if (stop_signal != TARGET_SIGNAL_TRAP)
        {
@@ -444,6 +465,5 @@ startup_inferior (int ntraps)
          resume (0, TARGET_SIGNAL_0);  /* Just make it go on */
        }
     }
-#endif /* STARTUP_INFERIOR */
-  stop_soon_quietly = NO_STOP_QUIETLY;
+  stop_soon = NO_STOP_QUIETLY;
 }
This page took 0.02531 seconds and 4 git commands to generate.