Re: trailing comments prevent whitespace removal

Paul Smith <[email protected]>
Newsgroups gmane.comp.gnu.make.bugs
Organization GNU's Not UNIX!
Message-ID <[email protected]>
On Mon, 2025-03-10 at 12:38 -0800, Britton Kerin wrote:
> I would expect make to remove trailing comments and then strip
> surrounding white space from variable definitions as usual but it
> seems that the comments prevent further stripping:

Comments don't prevent stripping; values in assignments are never
stripped on the right side; if you remove the comment but preserve the
trailing spaces those trailing spaces will still appear in the value. 
If you're not seeing this behavior then probably your editor is
stripping the spaces for you before saving the file; use "cat -e" or
something to verify the contents.

This is well-known make behavior for almost 50 years, and is required
by POSIX.

For example, from the POSIX spec:

> The value of string2 is defined as all characters from the first non-
> <blank> character, if any, after the <equals-sign>, up to but not
> including a comment character ('#') or an unescaped <newline>.

(where "string2" is the text on the right-hand side of the assignment
operator)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.