From: Nils ANDRÉ-CHANG Date: Sat, 9 Feb 2019 14:22:08 +0000 (+0000) Subject: Add proper return code for i3-msg X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=72ccd341fc07476137fea00d67cf7a61d3c99098;p=i3%2Fi3 Add proper return code for i3-msg --- diff --git a/i3-msg/main.c b/i3-msg/main.c index fe111416..0ada5f64 100644 --- a/i3-msg/main.c +++ b/i3-msg/main.c @@ -67,6 +67,7 @@ typedef struct reply_t { char *errorposition; } reply_t; +static int exit_code = 0; static reply_t last_reply; static int reply_boolean_cb(void *params, int val) { @@ -100,6 +101,7 @@ static int reply_end_map_cb(void *params) { fprintf(stderr, "ERROR: %s\n", last_reply.errorposition); } fprintf(stderr, "ERROR: %s\n", last_reply.error); + exit_code = 2; } return 1; } @@ -326,5 +328,5 @@ int main(int argc, char *argv[]) { close(sockfd); - return 0; + return exit_code; } diff --git a/man/i3-msg.man b/man/i3-msg.man index 625131de..ce9b476d 100644 --- a/man/i3-msg.man +++ b/man/i3-msg.man @@ -90,6 +90,15 @@ See the -m option for continuous monitoring. i3-msg is a sample implementation for a client using the unix socket IPC interface to i3. +=== Exit status: + +0: +if OK, +1: +if invalid syntax or unable to connect to ipc-socket +2: +if i3 returned an error processing your command(s) + == EXAMPLES ------------------------------------------------