NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: toolchain/46750: make oddity expanding variables assigned to with +=
The following reply was made to PR toolchain/46750; it has been noted by GNATS.
From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: toolchain/46750: make oddity expanding variables assigned to
with +=
Date: Mon, 30 Jul 2012 07:30:21 +0000
On Sun, Jul 29, 2012 at 02:25:02PM +0000, Edgar Fu? wrote:
> > This is the way make works.
> Then either the first element (e.g. :[1]) should be empty or start with =
> a space.
:[1] gives the first word; since words are delimited by whitespace,
any leading whitespace is not part of the first word.
> You currently get different results from
> - asking for the whole value, which should be a space-separated list =
> (you get " foo bar")
> - asking explicitly for a space-separated list (you get "foo bar")
> - asking for the individual elements and space-joining them (you get =
> "foo bar")
>
> > Whitespace after =3D (or :=3D) can be removed, but whitespace
> > after +=3D must be kept - otherwise you can't build strings.
>
> The manpage says (for all variants of assignments):
> Any white-space before the assigned value is removed=
It is.
What it's doing is inserting a space between the old value of the
variable and the appended material. This is what it's supposed to do;
otherwise, if you did
FOO=bar
FOO+=baz
you'd get "barbaz" instead of "bar baz".
The problem is that it's doing this even if the old value is the empty
string, so you get a leading space. Relatedly, if you do
FOO=foo
FOO+=
FOO+=
FOO+=
foo:
echo /${FOO}/
you get
/foo /
which is also wrong.
--
David A. Holland
dholland%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index