Subject: Re: pkg/36257 (games/wesnoth has msgfmt problems (plurals) [NetBSD 3.0])
To: None <,,>
From: Robert Elz <kre@munnari.OZ.AU>
List: pkgsrc-bugs
Date: 05/09/2007 16:10:04
The following reply was made to PR pkg/36257; it has been noted by GNATS.

From: Robert Elz <kre@munnari.OZ.AU>
Subject: Re: pkg/36257 (games/wesnoth has msgfmt problems (plurals) [NetBSD 3.0]) 
Date: Wed, 09 May 2007 23:07:04 +0700

     Date:        Wed,  9 May 2007 13:25:20 +0000 (UTC)
     Message-ID:  <>
   | Fix commited.  Please confirm again.
 Yes, it works with your (better) patch.   On NetBSD 3.0 anyway.
 However, there are two suggestions I'd make to make it even better.
 First, it is never really safe with test to use an unknown string
 variable unprotected in a = or != comparison.
 That is, in a test like
 	if test "$pofile" != "-"
 if the value of $pofile just happens to be "-e" or something like
 that, bad things happen (ie: nothing works the way you want, and
 usually the result is a bunch of strange error messages.)
 The usual fix is to protect at least the leading edge of the variable value,
 so it cannot possibly accidentally become a test operator, I like
 to do it like ...
 	if test "%${pofile}%" != "%-%"
 (the trailing '%' accomplishes  nothing useful, I use it for aesthetics
 (Note: you don't need, and cannot use, this trick on the operand of
 one of the file status test operators, for what I hope are obvious
 reasons, so the
 	-e "$pofile"
 needs to stay as it is.)
 Second, the test grammar has always been fragile, never really well
 defined (or it used not to be, maybe posix has fixed that), so that using
 complex test expressions (ones containing logical connectives, -a and -o)
 has tended to give different results on one version of test than another
 (it all ends up depending upon just what test decides to do first, in any
 particular implementation).
 To avoid that kind of problem, and especially these days with test being
 a built in command in every (Bourne type) shell worth mentioning, it is
 generally easier to use shell logical operators (&& and ||) and simply
 run multiple test commands.   So, instead of
 	if test "$pofile" != "-" -a ! -e "$pofile"
 	if test "%${pofile}%" != "%-%" && test ! -e "$pofile"
 (or something like that, many people just use X$var instead of %$var%,
 and others prefer the [ ... ] variant instead of "test" - none of that