Re: pkg/59981: xentools418 rc.d/xencommons: test: -z: unexpected operator

Robert Elz <[email protected]>
Newsgroups gmane.os.netbsd.devel.pkgsrc.bugs
Message-ID <[email protected]>
    Date:        Sun,  8 Feb 2026 04:45:00 +0000 (UTC)
    From:        "[email protected] via gnats" <[email protected]>
    Message-ID:  <[email protected]>

  | Arises from these conditionals -- first one is fine, second one is not:
  |
  | 	if test -n "$xenconsoled_pid" -a -n "$xenstored_pid";

That's not fine, it just happens to work (currently), it should be

	if test -n "$xenconsoled_pid" && test -n "$xenstored_pid"

(the "-n" operators can be omitted if desired).

  | 	if test -a -z "$xenconsoled_pid" -a -z "$xenstored_pid";

That one should probably (given what I see of the context) be

	if test -z "$xenconsoled_pid" || test -z "$xenstored_pid"

since it seems to be attempting to be the inverse of the first one
(ie: xencommons are running if both vars are set, and isn't otherwise.
that is, if either is not set.)

The second one could also be written

	if test -z "$xenconsoled_pid$xenstored_pid"

but that's obscure, and saves nothing worth saving, so don't go that way.

However that whole second if test (and the "fi" which precedes it, and
the "then" which follows) might just be able to be replaced by "else",
if what is in the PR is exactly as it is in the sources.  If that can be
done, it would certainly be better.

kre
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.