Yes, you are right, I haven’t tested it thoroughly enough, the output value is “;” regardless whether the command succeeds or fails. So you really have to use the on-error to learn the actual result. So it would look as follows:
:local result yes
:do {tool fetch url="https://1.1.1.1/dns-query\?name=mikrotik.ca%26type=A" output=file dst-path=result \
http-header-field=accept:application/dns-json} on-error={:set result no}
:if $result do={
/ip dns set servers="" use-doh-server=https://1.1.1.1/dns-query
} else={
/ip dns set servers=8.8.8.8 use-doh-server=""
}
(use of the result string as a variable name has nothing to do with its use as a name of the destination file for the :tool fetch)
This is an example of where the context makes a difference. :do is a command itself, and on-error is one of its parameters; do= is a parameter of an :if command. One of other symptoms of ROS’ tolerance is that you may omit the parameter name for some mandatory parameters. So instead of the proper :do command={:put “this”}, you can abbreviate to :do {:put “this”}. With :if, it is the same case: the proper syntax is actually :if condition=($a=$b) do={:put “equals”}, but most people write just :if ($a=$b) do={:put “equals”}