grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Fix target tool check logic


From: Yoshinori K. Okuji
Subject: Re: [PATCH] Fix target tool check logic
Date: Wed, 15 Apr 2009 00:45:45 +0900
User-agent: KMail/1.9.10

On Saturday 11 April 2009 22:16:58 Pavel Roskin wrote:
> Quoting "Yoshinori K. Okuji" <address@hidden>:
> > "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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]