specifying gdb's exit code

Message ID 87ppk89dir.fsf@fleche.redhat.com
State Superseded
Headers

Commit Message

Tom Tromey April 23, 2014, 5:11 p.m. UTC
  >>>>> "Daniel" == Daniel Gutson <daniel.gutson@tallertechnologies.com> writes:

Daniel> What about this?
Daniel> (I'm not a native English speaker)

I wonder what you think of the appended.
It adds an explicit "Usage" line, which gdb does in a few other spots
and which I think it generally the most clear approach.

Tom
  

Comments

Pedro Alves April 23, 2014, 5:29 p.m. UTC | #1
On 04/23/2014 06:11 PM, Tom Tromey wrote:
> -  add_com ("quit", class_support, quit_command, _("Exit gdb."));
> +  add_com ("quit", class_support, quit_command, _("\
> +Exit gdb.\n\
> +Usage: quit [CODE]\n\
> +The optional argument CODE, if present, is used as gdb's exit status.\n\
> +The default is zero."));
>    c = add_com ("help", class_support, help_command,
>  	       _("Print list of commands."));
>    set_cmd_completer (c, command_completer);

Would it be good if the online help and the manual agreed a bit
more?  The manual says "quit [expression]":

 @node Quitting GDB
 @section Quitting @value{GDBN}
 @cindex exiting @value{GDBN}
 @cindex leaving @value{GDBN}

 @table @code
 @kindex quit @r{[}@var{expression}@r{]}
 @kindex q @r{(@code{quit})}
 @item quit @r{[}@var{expression}@r{]}
 @itemx q
 To exit @value{GDBN}, use the @code{quit} command (abbreviated
 @code{q}), or type an end-of-file character (usually @kbd{Ctrl-d}).  If you
 do not supply @var{expression}, @value{GDBN} will terminate normally;
 otherwise it will terminate using the result of @var{expression} as the
 error code.
 @end table
  
Eli Zaretskii April 23, 2014, 5:29 p.m. UTC | #2
> From: Tom Tromey <tromey@redhat.com>
> Cc: gdb-patches <gdb-patches@sourceware.org>
> Date: Wed, 23 Apr 2014 11:11:40 -0600
> 
> >>>>> "Daniel" == Daniel Gutson <daniel.gutson@tallertechnologies.com> writes:
> 
> Daniel> What about this?
> Daniel> (I'm not a native English speaker)
> 
> I wonder what you think of the appended.
> It adds an explicit "Usage" line, which gdb does in a few other spots
> and which I think it generally the most clear approach.

Looks fine to me, thanks.
  
Paul_Koning@Dell.com April 23, 2014, 5:35 p.m. UTC | #3
On Apr 23, 2014, at 1:29 PM, Pedro Alves <alves.ped@gmail.com> wrote:

> On 04/23/2014 06:11 PM, Tom Tromey wrote:
>> -  add_com ("quit", class_support, quit_command, _("Exit gdb."));
>> +  add_com ("quit", class_support, quit_command, _("\
>> +Exit gdb.\n\
>> +Usage: quit [CODE]\n\
>> +The optional argument CODE, if present, is used as gdb's exit status.\n\
>> +The default is zero."));
>>   c = add_com ("help", class_support, help_command,
>> 	       _("Print list of commands."));
>>   set_cmd_completer (c, command_completer);
> 
> Would it be good if the online help and the manual agreed a bit
> more?  The manual says "quit [expression]":
> 
> @node Quitting GDB
> @section Quitting @value{GDBN}
> @cindex exiting @value{GDBN}
> @cindex leaving @value{GDBN}
> 
> @table @code
> @kindex quit @r{[}@var{expression}@r{]}
> @kindex q @r{(@code{quit})}
> @item quit @r{[}@var{expression}@r{]}
> @itemx q
> To exit @value{GDBN}, use the @code{quit} command (abbreviated
> @code{q}), or type an end-of-file character (usually @kbd{Ctrl-d}).  If you
> do not supply @var{expression}, @value{GDBN} will terminate normally;
> otherwise it will terminate using the result of @var{expression} as the
> error code.
> @end table

I think it should say “exit code” rather than “error code”.  Whether a given expression value is the code for an error depends on the value and on the host OS.

	paul
  
Pedro Alves April 23, 2014, 5:45 p.m. UTC | #4
On 04/23/2014 06:35 PM, Paul_Koning@Dell.com wrote:
> 
> On Apr 23, 2014, at 1:29 PM, Pedro Alves <alves.ped@gmail.com> wrote:

>> Would it be good if the online help and the manual agreed a bit
>> more?  The manual says "quit [expression]":

>> To exit @value{GDBN}, use the @code{quit} command (abbreviated
>> @code{q}), or type an end-of-file character (usually @kbd{Ctrl-d}).  If you
>> do not supply @var{expression}, @value{GDBN} will terminate normally;
>> otherwise it will terminate using the result of @var{expression} as the
>> error code.
>> @end table
> 
> I think it should say “exit code” rather than “error code”.  Whether a given expression value is the code for an error depends on the value and on the host OS.

Agreed.  I'd even call that an obvious change to the manual.
  

Patch

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index bfcd975..298f54c 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1685,7 +1685,11 @@  strict == evaluate script according to filename extension, error if not supporte
 			show_script_ext_mode,
 			&setlist, &showlist);
 
-  add_com ("quit", class_support, quit_command, _("Exit gdb."));
+  add_com ("quit", class_support, quit_command, _("\
+Exit gdb.\n\
+Usage: quit [CODE]\n\
+The optional argument CODE, if present, is used as gdb's exit status.\n\
+The default is zero."));
   c = add_com ("help", class_support, help_command,
 	       _("Print list of commands."));
   set_cmd_completer (c, command_completer);