* fork-child.c (escape_bang_in_quoted_argument): New function.
authorJoel Brobecker <brobecker@gnat.com>
Thu, 8 May 2003 18:08:57 +0000 (18:08 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Thu, 8 May 2003 18:08:57 +0000 (18:08 +0000)
        (fork_inferior): Escape '!' characters in quoted arguments
        only when needed.

gdb/ChangeLog
gdb/fork-child.c

index ffdb907d5b54f76c77688114bd7012d4bce4fc6a..ce84ed74d3dd9bd4bb249ff60399a68065ef68f2 100644 (file)
@@ -1,3 +1,9 @@
+2002-05-08  J. Brobecker  <brobecker@gnat.com>
+
+       * fork-child.c (escape_bang_in_quoted_argument): New function.
+       (fork_inferior): Escape '!' characters in quoted arguments
+       only when needed.
+
 2003-05-08  J. Brobecker  <brobecker@gnat.com>
 
        * dwarf2read.c (set_cu_language): Set the language to "minimal" if
index 738898a3eb35118b27e376154866b44f3673c7d6..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);
This page took 0.027958 seconds and 4 git commands to generate.