unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Wolfgang Schnerring <wosc@wosc.de>
To: 6963@debbugs.gnu.org
Subject: bug#6963: More usecases, patch attached
Date: Wed, 29 Sep 2010 08:09:18 +0200	[thread overview]
Message-ID: <20100929060918.GB9654@elzar.ws.whq.gocept.com> (raw)
In-Reply-To: <201009011216.17097.arne_bab@web.de>


[-- Attachment #1.1: Type: text/plain, Size: 868 bytes --]

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

[-- Attachment #1.2: emacsclient-exitstatus.patch --]
[-- Type: text/plain, Size: 1116 bytes --]

=== 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 = EXIT_SUCCESS;
 
   main_argv = argv;
   progname = argv[0];
@@ -1746,6 +1747,7 @@
             printf ("\n");
           fprintf (stderr, "*ERROR*: %s", str);
           needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
+          exit_status = EXIT_FAILURE;
         }
 #ifdef SIGSTOP
       else if (strprefix ("-suspend ", string))
@@ -1764,6 +1766,7 @@
             printf ("\n");
           printf ("*ERROR*: Unknown message: %s", string);
           needlf = string[0] == '\0' ? needlf : string[strlen (string) - 1] != '\n';
+          exit_status = EXIT_FAILURE;
         }
     }
 
@@ -1773,7 +1776,7 @@
   fsync (1);
 
   CLOSE_SOCKET (emacs_socket);
-  return EXIT_SUCCESS;
+  return exit_status;
 }
 
 #endif /* HAVE_SOCKETS && HAVE_INET_SOCKETS */


[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]

  reply	other threads:[~2010-09-29  6:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-01 10:16 bug#6963: 23.2; emacsclient -e "(remember-other-frame)" doesn’t give an error-code on error Arne Babenhauserheide
2010-09-29  6:09 ` Wolfgang Schnerring [this message]
2010-09-29  7:02   ` bug#6963: More usecases, patch attached Thierry Volpiatto
2010-09-29 14:42   ` Juanma Barranquero
2010-09-29 15:08     ` Wolfgang Schnerring
2010-09-29 15:43       ` Juanma Barranquero
2010-09-29 18:01         ` Wolfgang Schnerring
2010-09-30  1:52     ` Juanma Barranquero
2010-10-03  0:00       ` Chong Yidong
2010-10-03  0:38         ` Juanma Barranquero
2010-10-03  4:55           ` Chong Yidong
2010-10-03 10:44             ` Juanma Barranquero
2010-10-22 21:23 ` bug#6963: Thank you! Arne Babenhauserheide

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100929060918.GB9654@elzar.ws.whq.gocept.com \
    --to=wosc@wosc.de \
    --cc=6963@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).