bug-make
[Top][All Lists]
Advanced

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

Re: Bug with comment parsing and variable expansion


From: Rafaël Carré
Subject: Re: Bug with comment parsing and variable expansion
Date: Tue, 9 Nov 2010 17:00:55 +0100

On Tue, 09 Nov 2010 10:24:11 -0500
Paul Smith <address@hidden> wrote:

> On Tue, 2010-11-09 at 15:47 +0100, Rafaël Carré wrote:
> > Hello,
> > 
> > I believe I've found a bug in make 3.81, or at least some confusing
> > behaviour.
> > 
> > Here is a comparison of GNU make and netbsd 'pmake'
> > 
> > A-$(X) isn't expanded to "A-1" because of the comment on the line
> > where X is set, although X is set to "1"
> 
> X is not set to "1".  It's set to "1 " (note trailing space).  This is
> documented and required by the POSIX standard: trailing whitespace on
> a variable assignment is preserved.

Thanks for the explanation

> > % cat Makefile 
> > X = 1 #comment
> > Y = 1
> > A-$(X) = a
> > B-$(Y) = b
> > 
> > all:
> >     @echo $(X) $(A-1)
> >     @echo $(Y) $(B-1)
> 
> It's a hugely bad idea to use simple "echo" when trying to see values,
> because the shell will eat whitespace differences.  You should quote
> the values and add characters before and after, like this:
> 
> all:
>       @echo '|$(X)|   |$(A-1)|'
>       @echo '|$(Y)|   |$(B-1)|'
> 
> then you will immediately see the difference.

Ok, i'll remember to use this

-- 
✍ Rafaël Carré ☺

Attachment: signature.asc
Description: PGP signature


reply via email to

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