Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] "New" command "!"
@ 2011-11-08  9:38 Doug Evans
  2011-11-08 14:56 ` Tom Tromey
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Doug Evans @ 2011-11-08  9:38 UTC (permalink / raw)
  To: gdb-patches

Hi.
I mentioned this before in an offhand comment,
but now I'm submitting this RFC.
I'll add tests,docs,NEWS if the code part is ok.

Am I missing something?
Is there a reason not to add this?

2011-11-08  Doug Evans  <dje@google.com>

	New command "!", not just for xdb.
	* 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.

Index: cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.118
diff -u -p -r1.118 cli-cmds.c
--- cli/cli-cmds.c	1 Nov 2011 14:51:22 -0000	1.118
+++ cli/cli-cmds.c	8 Nov 2011 09:21:42 -0000
@@ -1825,14 +1825,7 @@ Two arguments (separated by a comma) are
   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: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.98
diff -u -p -r1.98 cli-decode.c
--- cli/cli-decode.c	9 Oct 2011 22:21:42 -0000	1.98
+++ cli/cli-decode.c	8 Nov 2011 09:30:22 -0000
@@ -1127,11 +1127,16 @@ find_command_name_length (const char *te
      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;


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] "New" command "!"
  2011-11-08  9:38 [RFC] "New" command "!" Doug Evans
@ 2011-11-08 14:56 ` Tom Tromey
  2011-11-08 15:36 ` Hui Zhu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2011-11-08 14:56 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> Am I missing something?
Doug> Is there a reason not to add this?

It seems reasonable to me.

Tom


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] "New" command "!"
  2011-11-08  9:38 [RFC] "New" command "!" Doug Evans
  2011-11-08 14:56 ` Tom Tromey
@ 2011-11-08 15:36 ` Hui Zhu
  2011-11-08 15:44 ` Tom Tromey
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Hui Zhu @ 2011-11-08 15:36 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

Cool!
Then cmdline can call shell cmd like ftp?  That is great.

Thanks,
Hui

On Tue, Nov 8, 2011 at 17:37, Doug Evans <dje@google.com> wrote:
> Hi.
> I mentioned this before in an offhand comment,
> but now I'm submitting this RFC.
> I'll add tests,docs,NEWS if the code part is ok.
>
> Am I missing something?
> Is there a reason not to add this?
>
> 2011-11-08  Doug Evans  <dje@google.com>
>
>        New command "!", not just for xdb.
>        * 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.
>
> Index: cli/cli-cmds.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
> retrieving revision 1.118
> diff -u -p -r1.118 cli-cmds.c
> --- cli/cli-cmds.c      1 Nov 2011 14:51:22 -0000       1.118
> +++ cli/cli-cmds.c      8 Nov 2011 09:21:42 -0000
> @@ -1825,14 +1825,7 @@ Two arguments (separated by a comma) are
>   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: cli/cli-decode.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
> retrieving revision 1.98
> diff -u -p -r1.98 cli-decode.c
> --- cli/cli-decode.c    9 Oct 2011 22:21:42 -0000       1.98
> +++ cli/cli-decode.c    8 Nov 2011 09:30:22 -0000
> @@ -1127,11 +1127,16 @@ find_command_name_length (const char *te
>      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;
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] "New" command "!"
  2011-11-08  9:38 [RFC] "New" command "!" Doug Evans
  2011-11-08 14:56 ` Tom Tromey
  2011-11-08 15:36 ` Hui Zhu
@ 2011-11-08 15:44 ` Tom Tromey
  2011-11-08 15:51 ` Pedro Alves
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2011-11-08 15:44 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> Am I missing something?
Doug> Is there a reason not to add this?

BTW, this is PR 7200.

Tom


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] "New" command "!"
  2011-11-08  9:38 [RFC] "New" command "!" Doug Evans
                   ` (2 preceding siblings ...)
  2011-11-08 15:44 ` Tom Tromey
@ 2011-11-08 15:51 ` Pedro Alves
  2011-11-08 17:26 ` Doug Evans
  2011-11-11 17:19 ` [doc RFA] " Doug Evans
  5 siblings, 0 replies; 9+ messages in thread
From: Pedro Alves @ 2011-11-08 15:51 UTC (permalink / raw)
  To: gdb-patches; +Cc: Doug Evans

On Tuesday 08 November 2011 09:37:58, Doug Evans wrote:
> Hi.
> I mentioned this before in an offhand comment,
> but now I'm submitting this RFC.
> I'll add tests,docs,NEWS if the code part is ok.
> 
> Am I missing something?
> Is there a reason not to add this?

Looks good to me too.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] "New" command "!"
  2011-11-08  9:38 [RFC] "New" command "!" Doug Evans
                   ` (3 preceding siblings ...)
  2011-11-08 15:51 ` Pedro Alves
@ 2011-11-08 17:26 ` Doug Evans
  2011-11-11 17:19 ` [doc RFA] " Doug Evans
  5 siblings, 0 replies; 9+ messages in thread
From: Doug Evans @ 2011-11-08 17:26 UTC (permalink / raw)
  To: gdb-patches

On Tue, Nov 8, 2011 at 1:37 AM, Doug Evans <dje@google.com> wrote:
> Hi.
> I mentioned this before in an offhand comment,
> but now I'm submitting this RFC.
> I'll add tests,docs,NEWS if the code part is ok.
>
> Am I missing something?
> Is there a reason not to add this?
>
> 2011-11-08  Doug Evans  <dje@google.com>
>
>        New command "!", not just for xdb.
>        * 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.
>
> Index: cli/cli-cmds.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
> retrieving revision 1.118
> diff -u -p -r1.118 cli-cmds.c
> --- cli/cli-cmds.c      1 Nov 2011 14:51:22 -0000       1.118
> +++ cli/cli-cmds.c      8 Nov 2011 09:21:42 -0000
> @@ -1825,14 +1825,7 @@ Two arguments (separated by a comma) are
>   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: cli/cli-decode.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
> retrieving revision 1.98
> diff -u -p -r1.98 cli-decode.c
> --- cli/cli-decode.c    9 Oct 2011 22:21:42 -0000       1.98
> +++ cli/cli-decode.c    8 Nov 2011 09:30:22 -0000
> @@ -1127,11 +1127,16 @@ find_command_name_length (const char *te
>      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;

I could only find the "/" and "?" commands in xdb mode that use those
characters.  Treating them the same as '!' is in this patch (if
xdb_commands) would allow "p/x" to work in xdb mode.
I'm not sure it's of much use, but IWBN to remove / and ? from the
above while loop.  OTOH, I think I'll leave it for another patch.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [doc RFA] "New" command "!"
  2011-11-08  9:38 [RFC] "New" command "!" Doug Evans
                   ` (4 preceding siblings ...)
  2011-11-08 17:26 ` Doug Evans
@ 2011-11-11 17:19 ` Doug Evans
  2011-11-11 19:31   ` Eli Zaretskii
  5 siblings, 1 reply; 9+ messages in thread
From: Doug Evans @ 2011-11-11 17:19 UTC (permalink / raw)
  To: gdb-patches, Eli Zaretskii

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]

Hi.

Ok to commit?

2011-11-11  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.

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

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

[-- Attachment #2: gdb-111111-bang-2.patch.txt --]
[-- Type: text/plain, Size: 4827 bytes --]

2011-11-11  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.

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

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

Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.464
diff -u -p -r1.464 NEWS
--- NEWS	2 Nov 2011 23:44:19 -0000	1.464
+++ NEWS	11 Nov 2011 15:46:51 -0000
@@ -104,6 +104,12 @@
   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: cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.118
diff -u -p -r1.118 cli-cmds.c
--- cli/cli-cmds.c	1 Nov 2011 14:51:22 -0000	1.118
+++ cli/cli-cmds.c	11 Nov 2011 15:46:51 -0000
@@ -1825,14 +1825,7 @@ Two arguments (separated by a comma) are
   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: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.98
diff -u -p -r1.98 cli-decode.c
--- cli/cli-decode.c	9 Oct 2011 22:21:42 -0000	1.98
+++ cli/cli-decode.c	11 Nov 2011 15:54:29 -0000
@@ -1127,11 +1127,16 @@ find_command_name_length (const char *te
      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: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.890
diff -u -p -r1.890 gdb.texinfo
--- doc/gdb.texinfo	8 Nov 2011 21:34:18 -0000	1.890
+++ doc/gdb.texinfo	11 Nov 2011 15:46:51 -0000
@@ -1347,8 +1347,10 @@ just use the @code{shell} command.
 
 @table @code
 @kindex shell
+@kindex !
 @cindex shell escape
 @item shell @var{command string}
+@itemx ! @var{command string}
 Invoke a standard shell to execute @var{command string}.
 If it exists, the environment variable @code{SHELL} determines which
 shell to run.  Otherwise @value{GDBN} uses the default shell
Index: testsuite/gdb.base/shell.exp
===================================================================
RCS file: testsuite/gdb.base/shell.exp
diff -N testsuite/gdb.base/shell.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/shell.exp	11 Nov 2011 15:51:36 -0000
@@ -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"

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [doc RFA] "New" command "!"
  2011-11-11 17:19 ` [doc RFA] " Doug Evans
@ 2011-11-11 19:31   ` Eli Zaretskii
  2011-11-15 17:00     ` Doug Evans
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2011-11-11 19:31 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

> Date: Fri, 11 Nov 2011 09:18:55 -0800
> From: Doug Evans <dje@google.com>
> 
> --- NEWS	2 Nov 2011 23:44:19 -0000	1.464
> +++ NEWS	11 Nov 2011 15:46:51 -0000
> @@ -104,6 +104,12 @@
>    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.

This is okay.

>  @item shell @var{command string}
> +@itemx ! @var{command string}

There should be no space between `!' and the rest, right?

Also, I'd suggest to tell here explicitly what you told in NEWS:

  Note that no space is needed between @code{!} and @var{command string}.

Btw, it is customary not to have spaces in @var.  Use hyphens or
underscores instead.  (Yes, I know it was that way before you added
the alias.)

Thanks.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [doc RFA] "New" command "!"
  2011-11-11 19:31   ` Eli Zaretskii
@ 2011-11-15 17:00     ` Doug Evans
  0 siblings, 0 replies; 9+ messages in thread
From: Doug Evans @ 2011-11-15 17:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1530 bytes --]

On Fri, Nov 11, 2011 at 11:29 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Fri, 11 Nov 2011 09:18:55 -0800
>> From: Doug Evans <dje@google.com>
>>
>> --- NEWS      2 Nov 2011 23:44:19 -0000       1.464
>> +++ NEWS      11 Nov 2011 15:46:51 -0000
>> @@ -104,6 +104,12 @@
>>    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.
>
> This is okay.
>
>>  @item shell @var{command string}
>> +@itemx ! @var{command string}
>
> There should be no space between `!' and the rest, right?
>
> Also, I'd suggest to tell here explicitly what you told in NEWS:
>
>  Note that no space is needed between @code{!} and @var{command string}.
>
> Btw, it is customary not to have spaces in @var.  Use hyphens or
> underscores instead.  (Yes, I know it was that way before you added
> the alias.)
>
> Thanks.
>

Here is what I committed.

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.

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

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

[-- Attachment #2: gdb-111114-bang-3.patch.txt --]
[-- Type: text/plain, Size: 5064 bytes --]

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.

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

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

Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.466
diff -u -p -r1.466 NEWS
--- NEWS	14 Nov 2011 20:07:20 -0000	1.466
+++ NEWS	15 Nov 2011 04:58:33 -0000
@@ -103,6 +103,12 @@
   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: cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.118
diff -u -p -r1.118 cli-cmds.c
--- cli/cli-cmds.c	1 Nov 2011 14:51:22 -0000	1.118
+++ cli/cli-cmds.c	15 Nov 2011 04:58:33 -0000
@@ -1825,14 +1825,7 @@ Two arguments (separated by a comma) are
   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: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.98
diff -u -p -r1.98 cli-decode.c
--- cli/cli-decode.c	9 Oct 2011 22:21:42 -0000	1.98
+++ cli/cli-decode.c	15 Nov 2011 04:58:33 -0000
@@ -1127,11 +1127,16 @@ find_command_name_length (const char *te
      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: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.895
diff -u -p -r1.895 gdb.texinfo
--- doc/gdb.texinfo	14 Nov 2011 20:07:23 -0000	1.895
+++ doc/gdb.texinfo	15 Nov 2011 04:58:33 -0000
@@ -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: testsuite/gdb.base/shell.exp
===================================================================
RCS file: testsuite/gdb.base/shell.exp
diff -N testsuite/gdb.base/shell.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/shell.exp	15 Nov 2011 04:58:34 -0000
@@ -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"

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-11-15 17:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-08  9:38 [RFC] "New" command "!" Doug Evans
2011-11-08 14:56 ` Tom Tromey
2011-11-08 15:36 ` Hui Zhu
2011-11-08 15:44 ` Tom Tromey
2011-11-08 15:51 ` Pedro Alves
2011-11-08 17:26 ` Doug Evans
2011-11-11 17:19 ` [doc RFA] " Doug Evans
2011-11-11 19:31   ` Eli Zaretskii
2011-11-15 17:00     ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox