From 27b86877b764e0e0bd988efbcf0f422574fd409f Mon Sep 17 00:00:00 2001 From: David Schweikert Date: Sun, 7 Dec 2025 14:11:22 +0100 Subject: [PATCH] Allow --json also for loop-mode --- ci/test-16-json-output.pl | 2 +- doc/fping.pod | 2 +- src/fping.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ci/test-16-json-output.pl b/ci/test-16-json-output.pl index 08e9c59..c97c600 100644 --- a/ci/test-16-json-output.pl +++ b/ci/test-16-json-output.pl @@ -189,5 +189,5 @@ $cmd->stderr_is_eq(""); my $cmd = Test::Command->new(cmd => "fping -J 127.0.0.1"); $cmd->exit_is_num(1); $cmd->stdout_is_eq(""); -$cmd->stderr_is_eq("fping: option -J, --json requires -c or -C\n"); +$cmd->stderr_is_eq("fping: option -J, --json requires -c, -C, or -l\n"); } diff --git a/doc/fping.pod b/doc/fping.pod index fb61110..e868ac5 100644 --- a/doc/fping.pod +++ b/doc/fping.pod @@ -167,7 +167,7 @@ IPv4 only, requires root privileges or cap_net_raw. =item B<-J>, B<--json> -Format output JSON (-c or -C required) +Format output JSON (-c, -C, or -l required) Example usage: diff --git a/src/fping.c b/src/fping.c index e9d89bf..7f58b81 100644 --- a/src/fping.c +++ b/src/fping.c @@ -1072,8 +1072,8 @@ int main(int argc, char **argv) exit(1); } - if (json_flag && !count_flag) { - fprintf(stderr, "%s: option -J, --json requires -c or -C\n", prog); + if (json_flag && !count_flag && !loop_flag) { + fprintf(stderr, "%s: option -J, --json requires -c, -C, or -l\n", prog); exit(1); } @@ -3944,7 +3944,7 @@ void usage(int is_error) fprintf(out, " -D, --timestamp print timestamp before each output line\n"); fprintf(out, " --timestamp-format=FORMAT show timestamp in the given format (-D required): ctime|iso|rfc3339\n"); fprintf(out, " -e, --elapsed show elapsed time on return packets\n"); - fprintf(out, " -J, --json output in JSON format (-c or -C required)\n"); + fprintf(out, " -J, --json output in JSON format (-c, -C, or -l required)\n"); fprintf(out, " -n, --name show targets by name (reverse-DNS lookup for target IPs)\n"); fprintf(out, " -N, --netdata output compatible for netdata (-l -Q are required)\n"); fprintf(out, " -o, --outage show the accumulated outage time (lost packets * packet interval)\n"); -- 2.43.0