From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Wolfgang Schnerring Newsgroups: gmane.emacs.bugs Subject: bug#6963: More usecases, patch attached Date: Wed, 29 Sep 2010 08:09:18 +0200 Message-ID: <20100929060918.GB9654@elzar.ws.whq.gocept.com> References: <201009011216.17097.arne_bab@web.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mvpLiMfbWzRoNl4x" X-Trace: dough.gmane.org 1285742568 25136 80.91.229.12 (29 Sep 2010 06:42:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 29 Sep 2010 06:42:48 +0000 (UTC) To: 6963@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Sep 29 08:42:46 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P0qNK-0007gP-84 for geb-bug-gnu-emacs@m.gmane.org; Wed, 29 Sep 2010 08:42:46 +0200 Original-Received: from localhost ([127.0.0.1]:56858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0qNJ-0004j8-ND for geb-bug-gnu-emacs@m.gmane.org; Wed, 29 Sep 2010 02:42:45 -0400 Original-Received: from [140.186.70.92] (port=59564 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0qLz-0003nZ-7O for bug-gnu-emacs@gnu.org; Wed, 29 Sep 2010 02:41:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0qLy-0002gM-62 for bug-gnu-emacs@gnu.org; Wed, 29 Sep 2010 02:41:23 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49463) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0qLy-0002gC-4J for bug-gnu-emacs@gnu.org; Wed, 29 Sep 2010 02:41:22 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1P0q6A-0000oI-I5; Wed, 29 Sep 2010 02:25:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <201009011216.17097.arne_bab@web.de> Resent-From: Wolfgang Schnerring Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Sep 2010 06:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6963 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 6963-submit@debbugs.gnu.org id=B6963.12857414913095 (code B ref 6963); Wed, 29 Sep 2010 06:25:02 +0000 Original-Received: (at 6963) by debbugs.gnu.org; 29 Sep 2010 06:24:51 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0q5y-0000ns-9P for submit@debbugs.gnu.org; Wed, 29 Sep 2010 02:24:51 -0400 Original-Received: from pharos.wosc.de ([85.214.124.141]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0poC-0000QM-0N for 6963@debbugs.gnu.org; Wed, 29 Sep 2010 02:06:29 -0400 Original-Received: from [195.62.106.78] (helo=elzar.ws.whq.gocept.com) by pharos.wosc.de with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1P0pqw-0006lB-Pg for 6963@debbugs.gnu.org; Wed, 29 Sep 2010 08:09:18 +0200 Original-Received: from wosc by elzar.ws.whq.gocept.com with local (Exim 4.72) (envelope-from ) id 1P0pqw-0008Tr-3t for 6963@debbugs.gnu.org; Wed, 29 Sep 2010 08:09:18 +0200 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Mailman-Approved-At: Wed, 29 Sep 2010 02:24:50 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 29 Sep 2010 02:25:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Wed, 29 Sep 2010 02:42:40 -0400 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:40532 Archived-At: --mvpLiMfbWzRoNl4x Content-Type: multipart/mixed; boundary="uQr8t48UFsdbeI+V" Content-Disposition: inline --uQr8t48UFsdbeI+V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline emacsclient is such a usefull tool. But that it does not signal error situations via its exit status severely hinders its usage in shell scripts or in integration with other programs. For example, I was bit by this rather badly when I tried to use emacsclient to start an ediff session, to use as a merge tool for the Mercurial SCM. I may have made a typo in configuring said ediff command or for whatever other reason, Emacs returned an error. But Mercurial was blissfully unaware of this, since emacsclient returns 0 no matter what. End result: Mercurial committed a broken merge that I had to spend at least two hours some days later to debug. I've attached a patch that makes emacsclient exit with nonzero status when it receives an error message from Emacs -- it already *prints* "*ERROR*" in these cases, so I feel this makes a lot of sense. Thanks, Wolfgang --uQr8t48UFsdbeI+V Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="emacsclient-exitstatus.patch" Content-Transfer-Encoding: quoted-printable =3D=3D=3D modified file 'lib-src/emacsclient.c' --- lib-src/emacsclient.c 2010-08-11 08:20:34 +0000 +++ lib-src/emacsclient.c 2010-09-29 05:57:38 +0000 @@ -1506,6 +1506,7 @@ char *cwd, *str; char string[BUFSIZ+1]; int null_socket_name, null_server_file, start_daemon_if_needed; + int exit_status =3D EXIT_SUCCESS; =20 main_argv =3D argv; progname =3D argv[0]; @@ -1746,6 +1747,7 @@ printf ("\n"); fprintf (stderr, "*ERROR*: %s", str); needlf =3D str[0] =3D=3D '\0' ? needlf : str[strlen (str) - 1] != =3D '\n'; + exit_status =3D EXIT_FAILURE; } #ifdef SIGSTOP else if (strprefix ("-suspend ", string)) @@ -1764,6 +1766,7 @@ printf ("\n"); printf ("*ERROR*: Unknown message: %s", string); needlf =3D string[0] =3D=3D '\0' ? needlf : string[strlen (strin= g) - 1] !=3D '\n'; + exit_status =3D EXIT_FAILURE; } } =20 @@ -1773,7 +1776,7 @@ fsync (1); =20 CLOSE_SOCKET (emacs_socket); - return EXIT_SUCCESS; + return exit_status; } =20 #endif /* HAVE_SOCKETS && HAVE_INET_SOCKETS */ --uQr8t48UFsdbeI+V-- --mvpLiMfbWzRoNl4x Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) iD8DBQFMotgOYfWCHec7w7QRAr+RAJ0T77+joy5v+M5V5f+a/z0gP6JPiACgggWa LnIWXMkXQcep61vn9Cvzz9k= =mNjb -----END PGP SIGNATURE----- --mvpLiMfbWzRoNl4x--