]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Make "!" an alias for "shell".
authorDoug Evans <dje@google.com>
Tue, 15 Nov 2011 05:06:35 +0000 (05:06 +0000)
committerDoug Evans <dje@google.com>
Tue, 15 Nov 2011 05:06:35 +0000 (05:06 +0000)
* NEWS: Add mention.
* cli/cli-cmds.c (init_cli_cmds): Remove xdb_commands condition on
adding "!" command, always add it.
* cli/cli-decode.c (find_command_name_length): Recognize "!" as a
command of length one.

doc/
* gdb.texinfo (Shell Commands): Document "!".

testsuite/
* gdb.base/shell.exp: New file.

gdb/ChangeLog
gdb/NEWS
gdb/cli/cli-cmds.c
gdb/cli/cli-decode.c
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/shell.exp [new file with mode: 0644]

index cf8f7f80a9765956c2592c6f3504b94e37d99739..eefae5918d9dad3a0212969ff1680fcb4396eb10 100644 (file)
@@ -1,3 +1,12 @@
+2011-11-14  Doug Evans  <dje@google.com>
+
+       Make "!" an alias for "shell".
+       * NEWS: Add mention.
+       * cli/cli-cmds.c (init_cli_cmds): Remove xdb_commands condition on
+       adding "!" command, always add it.
+       * cli/cli-decode.c (find_command_name_length): Recognize "!" as a
+       command of length one.
+
 2011-11-14  Stan Shebs  <stan@codesourcery.com>
            Kwok Cheung Yeung  <kcy@codesourcery.com>
 
index dc16a4bc07ad6ba676fed226b15daae27e914f41..bce8e3c772c7a209825746cb32f4307ae272581f 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
   at the time the function got called.  Entry values are available only since
   gcc version 4.7.
 
+* New commands
+
+!SHELL COMMAND
+  "!" is now an alias of the "shell" command.
+  Note that no space is needed between "!" and SHELL COMMAND.
+
 * Changed commands
 
 watch EXPRESSION mask MASK_VALUE
index 94328c4411368001120fc4622fb0fc6478003a1c..d75a6c09f3e1abc1de9f475ace715fa94e8b2b99 100644 (file)
@@ -1825,14 +1825,7 @@ Two arguments (separated by a comma) are taken as a range of memory to dump,\n\
   if (xdb_commands)
     add_com_alias ("va", "disassemble", class_xdb, 0);
 
-  /* NOTE: cagney/2000-03-20: Being able to enter ``(gdb) !ls'' would
-     be a really useful feature.  Unfortunately, the below wont do
-     this.  Instead it adds support for the form ``(gdb) ! ls''
-     (i.e. the space is required).  If the ``!'' command below is
-     added the complains about no ``!'' command would be replaced by
-     complains about how the ``!'' command is broken :-)  */
-  if (xdb_commands)
-    add_com_alias ("!", "shell", class_support, 0);
+  add_com_alias ("!", "shell", class_support, 0);
 
   c = add_com ("make", class_support, make_command, _("\
 Run the ``make'' program using the rest of the line as arguments."));
index 08707827c62abb371023b19b08d26a1fe44f0c71..22ae6ec19ef2ea8a5552aec361039f8e2685cf99 100644 (file)
@@ -1127,11 +1127,16 @@ find_command_name_length (const char *text)
      Note that this is larger than the character set allowed when
      creating user-defined commands.  */
 
+  /* Recognize '!' as a single character command so that, e.g., "!ls"
+     works as expected.  */
+  if (*p == '!')
+    return 1;
+
   while (isalnum (*p) || *p == '-' || *p == '_'
         /* Characters used by TUI specific commands.  */
         || *p == '+' || *p == '<' || *p == '>' || *p == '$'
         /* Characters used for XDB compatibility.  */
-        || (xdb_commands && (*p == '!' || *p == '/' || *p == '?')))
+        || (xdb_commands && (*p == '/' || *p == '?')))
     p++;
 
   return p - text;
index 02ef07b13ddec47f20426f505a070eaaa55581ee..15659d6479b2340b266f15571f61f0e09c03a28b 100644 (file)
@@ -1,3 +1,7 @@
+2011-11-14  Doug Evans  <dje@google.com>
+
+       * gdb.texinfo (Shell Commands): Document "!".
+
 2011-11-14  Stan Shebs  <stan@codesourcery.com>
            Kwok Cheung Yeung  <kcy@codesourcery.com>
 
index 0cadc9681d39a4d15e2c0b83321b3be0595c29d9..9255b8953235f8705b53b020cfc2ed8355eed1d1 100644 (file)
@@ -1347,9 +1347,12 @@ just use the @code{shell} command.
 
 @table @code
 @kindex shell
+@kindex !
 @cindex shell escape
-@item shell @var{command string}
-Invoke a standard shell to execute @var{command string}.
+@item shell @var{command-string}
+@itemx !@var{command-string}
+Invoke a standard shell to execute @var{command-string}.
+Note that no space is needed between @code{!} and @var{command-string}.
 If it exists, the environment variable @code{SHELL} determines which
 shell to run.  Otherwise @value{GDBN} uses the default shell
 (@file{/bin/sh} on Unix systems, @file{COMMAND.COM} on MS-DOS, etc.).
index a53f52f3312a4bc693de4d1da4784f8493ddc486..d71e46c1e6264aba0d83ba61986d742426eb2a4a 100644 (file)
@@ -1,3 +1,7 @@
+2011-11-14  Doug Evans  <dje@google.com>
+
+       * gdb.base/shell.exp: New file.
+
 2011-11-14  Stan Shebs  <stan@codesourcery.com>
 
        * gdb.trace/ftrace.c: New.
diff --git a/gdb/testsuite/gdb.base/shell.exp b/gdb/testsuite/gdb.base/shell.exp
new file mode 100644 (file)
index 0000000..ce1223d
--- /dev/null
@@ -0,0 +1,24 @@
+# Copyright 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test that the shell and ! commands work.
+
+gdb_exit
+gdb_start
+
+gdb_test "shell echo foo" "foo"
+
+gdb_test "! echo foo" "foo"
+gdb_test "!echo foo" "foo"