bugmake - Bugs: bug #62381, use of hash (#) changed behavior...

 
 

bug #62381: use of hash (#) changed behavior 4.2 to 4.3

Submitter:  Scott Moser <smoser>
Submitted:  Thu 28 Apr 2022 02:36:12 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.3 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 06 May 2022 05:03:06 PM UTC, comment #4: 

@Paul,
Thanks for your time. Sorry I had not seen the NEWs file which does have a very good explanation.

Scott Moser <smoser>
Thu 28 Apr 2022 02:41:34 PM UTC, comment #3: 

It's not a duplicate of bug #60799 though: that's related to handling of second expansion.

Paul D. Smith <psmith>
Group administrator
Thu 28 Apr 2022 02:40:23 PM UTC, comment #2: 

This is discussed in the NEWS file for GNU make 4.3:


* WARNING: Backward-incompatibility!
  Number signs (#) appearing inside a macro reference or function invocation
  no longer introduce comments and should not be escaped with backslashes:
  thus a call such as:
    foo := $(shell echo '#')
  is legal.  Previously the number sign needed to be escaped, for example:
    foo := $(shell echo '\#')
  Now this latter will resolve to "\#".  If you want to write makefiles
  portable to both versions, assign the number sign to a variable:
    H := \#
    foo := $(shell echo '$H')
  This was claimed to be fixed in 3.81, but wasn't, for some reason.
  To detect this change search for 'nocomment' in the .FEATURES variable.


https://git.savannah.gnu.org/cgit/make.git/tree/NEWS?h=4.3#n18

Paul D. Smith <psmith>
Group administrator
Thu 28 Apr 2022 02:37:44 PM UTC, comment #1: 

I intended to say, this seems likely related to https://savannah.gnu.org/bugs/?60799 . Maybe it is a duplicate.

Scott Moser <smoser>
Thu 28 Apr 2022 02:36:12 PM UTC, original submission:  

I recently started using gnu make version 4.3, changing from 4.2.1, and hit a change in behavior on use of the "#" character.

I had this:


---- my.mk ----
foo := $(shell n="bar-bar"; echo ${{n\#\#*-})
debug:
    @echo foo=$(foo)
------

4.2.1 shows:
$ make -f my.mk
foo=bar

With 4.3 I get:
$ make -f my.mk
/bin/sh: 1: Bad substitution
foo=

The solution that works in both versions is:
--- my-fixed.mk ---
hash := \#
foo := $(shell n=bar-bar; echo $${n$(hash)$(hash)*-})
debug:
  @echo foo=$(foo)
---------

Scott Moser <smoser>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by smoser (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-04-28 psmith StatusNone Not A Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code