From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64424 invoked by alias); 5 Jul 2018 14:47:05 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 64412 invoked by uid 89); 5 Jul 2018 14:47:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,KAM_NUMSUBJECT,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=Gary, gary X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Jul 2018 14:47:03 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26DA681663FC for ; Thu, 5 Jul 2018 14:47:02 +0000 (UTC) Received: from blade.nx (ovpn-117-186.ams2.redhat.com [10.36.117.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE303111E418 for ; Thu, 5 Jul 2018 14:47:01 +0000 (UTC) Received: by blade.nx (Postfix, from userid 1000) id 473A3801A086; Thu, 5 Jul 2018 15:47:01 +0100 (BST) Date: Thu, 05 Jul 2018 14:47:00 -0000 From: Gary Benson To: gdb@sourceware.org Subject: gdb -batch always exits with status 0 Message-ID: <20180705144659.GA29169@blade.nx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg00009.txt.bz2 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/