tech-userlevel archive

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

bmake oddity with +=

I discovered an oddity how (b)make expands variables which have been 
assigned empty and then been added to using +=.

This Makefile (the underscores are just there to make leading blanks 
more obvious in the output):

x+= foo bar

        echo _${x}
        echo _${x:[1]}
        echo _${x:ts }


echo _ foo bar
_ foo bar
echo _foo
echo _foo bar
_foo bar

So x's first Element is "foo" (not " foo"), nevertheless x expands to 
" foo bar" (not "foo bar"). And explicitely asking the words to be 
separated by a space gives the expected result.

If you just assign to x (e.g. "x= foo bar"), it works as expected.

I suspect the inner workings of make are, err, interesting.

Home | Main Index | Thread Index | Old Index