Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* gdb -batch always exits with status 0
@ 2018-07-05 14:47 Gary Benson
  2018-07-05 14:55 ` Ruslan Kabatsayev
  2018-07-05 15:23 ` Paul Smith
  0 siblings, 2 replies; 11+ messages in thread
From: Gary Benson @ 2018-07-05 14:47 UTC (permalink / raw)
  To: gdb

Hi all,

I've been working on fixing PR gdb/13000, which is that GDB in batch
mode always exits with status 0 despite the manual saying it should
exit with nonzero status on error.  The latter is what I'd intuitively
expect, so I'm looking at fixing GDB to match the docs rather than
fixing the docs to match GDB.

A narrow fix to make GDB match the docs is actually fairly simple,
but I'm bothered that not only does gdb -batch always exit with
status 0, it actually continues over any number of errors before
doing so.  So you can do something like:

  bash$ echo nonsense > cmds
  bash$ echo garbage > .gdbinit
  bash$ gdb -batch -iex invalid-command -ex also-invalid \
          -cd /no/such/directory -p 1 -batch -ix /does/not/exist \
	  -x cmds
  Undefined command: "invalid-command".  Try "help".
  warning: /does/not/exist: No such file or directory
  /no/such/directory: No such file or directory.
  ptrace: Operation not permitted.
  .gdbinit:1: Error in sourced command file:
  Undefined command: "garbage".  Try "help".
  Undefined command: "also-invalid".  Try "help".
  cmds:1: Error in sourced command file:
  Undefined command: "nonsense".  Try "help".
  bash$ echo $?
  0

Would anybody object to my changing GDB's behaviour to terminate
on the first error in batch mode?

(I'd also like to remove the 'Try "help".' suffix when in batch mode,
though I'd likely do that in a separate patch.)

Cheers,
Gary

--
https://gbenson.net/


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

end of thread, other threads:[~2018-08-22  9:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-05 14:47 gdb -batch always exits with status 0 Gary Benson
2018-07-05 14:55 ` Ruslan Kabatsayev
2018-07-05 15:23 ` Paul Smith
2018-08-17 11:03   ` Gary Benson
2018-08-17 11:25     ` Ruslan Kabatsayev
2018-08-17 13:24     ` Paul Smith
2018-08-17 15:23       ` Gary Benson
2018-08-17 15:44         ` Ruslan Kabatsayev
2018-08-17 16:03           ` Gary Benson
2018-08-17 18:30             ` Pedro Alves
2018-08-22  9:07               ` Gary Benson

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