With the attached Makefile in an otherwise-empty directory, GNU 'make' 4.2.1
outputs:
V=$(expr " " : '\(.*[^ ]\)') && printf '%s\n' "$V"
make: *** [Makefile:2: this-should-work] Error 1
It should output:
V=$(expr " " : '\(.*[^\
]\)') && printf '%s\n' "$V"
(The line after the 'printf' line consists of a single space.)
The problem is that GNU 'make' transforms a newline into a space, even though
POSIX says the newline should be preserved; see the last paragraph of "Makefile
Syntax"
<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html#tag_20_76_13_01>.
Solaris 10 /usr/ccs/bin/make works correctly (if SHELL=/bin/bash is also
specified). Also, 'make this-works' works correctly with GNU 'make'.
This bug has been in GNU 'make' for some time; I can reproduce it with version
3.81.
this-should-work:
V=$$(expr " " : '\(.*[^\
]\)') && printf '%s\n' "$$V"
this-works:
pat='\(.*[^\
]\)' && \
V=$$(expr " " : "$$pat") && printf '%s\n' "$$V"
_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make