]> git.gsnw.org Git - fping.git/commitdiff
Fix the missing new line character on JSON output for an invalid host warning
authorGerman Service Network <support@gsnw.de>
Wed, 20 Aug 2025 10:59:14 +0000 (12:59 +0200)
committerSebastian <176771227+gsnw-sebast@users.noreply.github.com>
Fri, 22 Aug 2025 06:29:46 +0000 (08:29 +0200)
ci/test-16-json-output.pl
src/fping.c

index bcf159d5702a088f9eae5a9965076f9ddec86327..d3b8d657d4a52783905f99c200552984e06ff657 100644 (file)
@@ -153,7 +153,7 @@ $cmd->stderr_is_eq("");
 {
 my $cmd = Test::Command->new(cmd => "fping -J -c 1 -q host.invalid");
 $cmd->exit_is_num(2);  # Exit code 2 indicates name resolution error
-$cmd->stdout_like(qr/^\{"warning":\s\{"host":\s"host\.invalid",\s"message":\s"(?:Name or service not known|Temporary failure in name resolution|nodename nor servname provided, or not known)"\}\}$/);
+$cmd->stdout_like(qr/^\{"warning":\s\{"host":\s"host\.invalid",\s"message":\s"(?:Name or service not known|Temporary failure in name resolution|nodename nor servname provided, or not known)"\}\}\n$/);
 $cmd->stderr_is_eq("");
 }
 
index dcffd178df922d64387d9b3d656f6e8edf4978e6..e359d566ff440891a269f2c3d0f5c628dc673704 100644 (file)
@@ -3326,7 +3326,7 @@ void add_name(char *name)
 
         // Handle JSON output for invalid hosts
         if (json_flag) {
-            fprintf(stdout, "{\"warning\": {\"host\": \"%s\", \"message\": \"%s\"}}", name, gai_strerror(ret_ga));
+            fprintf(stdout, "{\"warning\": {\"host\": \"%s\", \"message\": \"%s\"}}\n", name, gai_strerror(ret_ga));
             return;
         }