All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yoshinori K. Okuji" <okuji@enbug.org>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] Fix target tool check logic
Date: Wed, 15 Apr 2009 00:45:45 +0900	[thread overview]
Message-ID: <200904150045.46154.okuji@enbug.org> (raw)
In-Reply-To: <20090411091658.bv4254n00sk00000-cebfxv@webmail.spamcop.net>

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



  reply	other threads:[~2009-04-14 15:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-11  4:58 [PATCH] Fix target tool check logic Pavel Roskin
2009-04-11 10:19 ` Yoshinori K. Okuji
2009-04-11 13:16   ` Pavel Roskin
2009-04-14 15:45     ` Yoshinori K. Okuji [this message]
2009-04-15  0:31       ` Pavel Roskin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200904150045.46154.okuji@enbug.org \
    --to=okuji@enbug.org \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.