Code

sysdb: When using -c, exit non-zero if any command failed.
[sysdb.git] / src / tools / sysdb / main.c
index 991e1ffb6d8e744252309646f4741e67abfe901d..8455a6c7000e4856483b8650ce02a932c0fa98a2 100644 (file)
@@ -184,6 +184,8 @@ execute_commands(sdb_client_t *client, sdb_llist_t *commands)
 
        while (sdb_llist_iter_has_next(iter)) {
                sdb_object_t *obj = sdb_llist_iter_get_next(iter);
+               int err;
+
                if (sdb_client_send(client, CONNECTION_QUERY,
                                        (uint32_t)strlen(obj->name), obj->name) <= 0) {
                        sdb_log(SDB_LOG_ERR, "Failed to send command '%s' to server",
@@ -191,8 +193,10 @@ execute_commands(sdb_client_t *client, sdb_llist_t *commands)
                        status = 1;
                        break;
                }
-               if (sdb_command_print_reply(client)) {
-                       sdb_log(SDB_LOG_ERR, "Failed to read reply from server");
+               err = sdb_command_print_reply(client);
+               if (err) {
+                       if (err < 0)
+                               sdb_log(SDB_LOG_ERR, "Failed to read reply from server");
                        status = 1;
                        break;
                }