tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: "host <tld>" returns 0 without any data



> Can somebody here explain to me why a DNS lookup of a TLD

(or, at least in my tests, any other node of the DNS tree that exists
but has no A/AAAA/MX records)

> causes the host(1) command to return successfully but not print any
> data?  Ie, (why) is this correct behaviour?

"That's how it's designed."  I don't see any documentation in the
manpage (at least not the 4.0.1 manpage, that being the most recent
version I have running) for the exit code, so (IMO) nothing should be
treating the exit code as meaningful.  For that matter, I don't see any
documentation in the manpage for what is output under what
circumstances, so it's all a matter of opinion and POLS.

Personally, I see no output in this case as the correct response in the
same sense that I see no output as the correct case for ls on an empty
directory: if there's nothing to print, print nothing.

> $ host -t A fr.
> fr has no A record

By the above lights, this is the incorrect case (especially since that
text goes to stdout, not stderr).

But, if host is specifically designed for human interaction, with
blabbiness a designed-in property, then the case without -t should
print something suitable (probably something like "%s has no A, AAAA,
or MX records").  The manpage does not make it clear whether host is
designed as a human-interface tool with verbose and imprecisely
specified output or whether it's a typical Unix tool suitable for use
in pipelines; this and the verbosity of the output when there _is_ data
lead me to think the former, in which case the no--t case is the one
that should be changed.

If I used host enough to care about it, I'd file a PR.  (I don't.  For
human use, I use dig; for automated use, I have a program "addr" that
just prints addresses, without commentary - I haven't wanted automated
command-line lookups of non-address records enough to bother
implementing them.)

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index