[Dnsmasq-discuss] dnsmasq --test > output to stderr

Simon Kelley simon at thekelleys.org.uk
Wed Mar 23 22:59:38 UTC 2022



On 23/03/2022 21:02, Ercolino de Spiacico wrote:
> It seems like "dnsmasq --test" redirects the output "syntax check OK" 
> message to stderr (2) by default:
> 
> 
> root at sparrow:/tmp# dnsmasq --test
> dnsmasq: syntax check OK.
> root at sparrow:/tmp# dnsmasq --test 1>/dev/null
> dnsmasq: syntax check OK.
> root at sparrow:/tmp# dnsmasq --test 2>/dev/null
> root at sparrow:/tmp#
> 
> Is this meant to be? If so is there any alternative way I could print 
> out only configuration issues and ignore "syntax check OK" messages?
> 
> Thanks
The relevant code looks like:

  if (testmode)
     {
       fprintf(stderr, "dnsmasq: %s.\n", _("syntax check OK"));
       exit(0);
     }

So it's not an accident, but the reason it's like that is rather lost in 
the mists of time.

Can you take advantage of the fact that the exit code is zero when the 
test passes, but non-zero if there's an error?


Cheers,

Simon.




> 
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss
> 



More information about the Dnsmasq-discuss mailing list