mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Merge pull request #2057 from RyanDwyer/swaymsg-fix-exit-code
swaymsg: Fix exit code
This commit is contained in:
		
						commit
						cc1fc3b4a6
					
				
					 1 changed files with 17 additions and 4 deletions
				
			
		| 
						 | 
					@ -19,13 +19,26 @@ void sway_terminate(int exit_code) {
 | 
				
			||||||
	exit(exit_code);
 | 
						exit(exit_code);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Iterate results array and return false if any of them failed
 | 
				
			||||||
static bool success(json_object *r, bool fallback) {
 | 
					static bool success(json_object *r, bool fallback) {
 | 
				
			||||||
	json_object *success;
 | 
						if (!json_object_is_type(r, json_type_array)) {
 | 
				
			||||||
	if (!json_object_object_get_ex(r, "success", &success)) {
 | 
					 | 
				
			||||||
		return fallback;
 | 
							return fallback;
 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		return json_object_get_boolean(success);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						size_t results_len = json_object_array_length(r);
 | 
				
			||||||
 | 
						if (!results_len) {
 | 
				
			||||||
 | 
							return fallback;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						for (size_t i = 0; i < results_len; ++i) {
 | 
				
			||||||
 | 
							json_object *result = json_object_array_get_idx(r, i);
 | 
				
			||||||
 | 
							json_object *success;
 | 
				
			||||||
 | 
							if (!json_object_object_get_ex(result, "success", &success)) {
 | 
				
			||||||
 | 
								return false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (!json_object_get_boolean(success)) {
 | 
				
			||||||
 | 
								return false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void pretty_print_cmd(json_object *r) {
 | 
					static void pretty_print_cmd(json_object *r) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue