Reputation: 224964
The GDB docs say:
-batch
Run in batch mode. Exit with status
0
after processing all the command files specified with ‘-x
’ ... Exit with nonzero status if an error occurs in executing the gdb commands in the command files.
But even when there are errors, I get an exit status of zero. For example:
$ cat gdbscript
foo
$ gdb -batch -x gdbscript
gdbscript:1: Error in sourced command file:
Undefined command: "foo". Try "help".
$ echo $?
0
The GDB program status is correct if I use quit 1
, for example, in the script.
Why is this happening to me? Is there a way around it? I'm trying to flash a remote target, and I'd really like GDB to exit with error status if it fails.
My GDB version, should it happen to be important:
GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs
Upvotes: 7
Views: 815
Reputation: 35726
Why is this happening to me? Is there a way around it?
It is known gdb Bug 13000. You can apply experimental patch from Bug 13000 and rebuild gdb which may work for you.
Upvotes: 3