On Saturday 11 April 2009 22:16:58 Pavel Roskin wrote: > Quoting "Yoshinori K. Okuji" <ok...@enbug.org>: > > "test -n" should be avoided. Maybe this is not necessary nowadays, but my > > old lesson was to use "test x$target_alias != x" instead for portability. > > Well, "!=" was not very portable, either, maybe. > > I believe both "-n" and "!=" are found in Autoconf sources that are > turned into configure scripts. Anyway, I'll use the syntax you want.
Even if this looks obsolete, I think it is better to follow the chapter "Limitations of Builtins" in the autoconf manual: `test' (strings) Posix says that `test "STRING"' succeeds if STRING is not null, but this usage is not portable to traditional platforms like Solaris 10 `/bin/sh', which mishandle strings like `!' and `-n'. Posix also says that `test ! "STRING"', `test -n "STRING"' and `test -z "STRING"' work with any string, but many shells (such as Solaris, AIX 3.2, UNICOS 10.0.0.6, Digital Unix 4, etc.) get confused if STRING looks like an operator: $ test -n = test: argument expected $ test ! -n test: argument expected Similarly, Posix says that both `test "STRING1" = "STRING2"' and `test "STRING1" != "STRING2"' work for any pairs of strings, but in practice this is not true for troublesome strings that look like operators or parentheses, or that begin with `-'. It is best to protect such strings with a leading `X', e.g., `test "XSTRING" != X' rather than `test -n "STRING"' or `test ! "STRING"'. Regards, Okuji _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel