bugmake - Bugs: bug #64112, ...\$(...) or ...\\$(...) give...

 
 

bug #64112: ...\$(...) or ...\\$(...) give unexpected result

Submitter:  Pascal J. Bourguignon <informatimago>
Submitted:  Wed 26 Apr 2023 08:10:40 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.1 Operating System:  None
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 26 Apr 2023 11:53:31 AM UTC, comment #1: 

I'm not sure which "comments in the source code" you're looking at, but that's not usually a good way to learn the behavior of the software: instead you should look at the user's manual: https://www.gnu.org/software/make/manual/html_node/Reference.html (first paragraph).

No version of make has ever used backslashes to escape make variable references: you double the '$'; e.g., $$(foo)

Paul D. Smith <psmith>
Group administrator
Wed 26 Apr 2023 08:10:40 AM UTC, original submission:  

1- the comments in the source code would seem to indicate that the intended effect of \$(foo) is to disable variable expansion, ie. to return a token \$(foo), and for \\$(foo), we should have a simple escape of the backslash, and the variable should be expanded, so with the following example, we should get \foofoo.
Instead, we get in both case ^Loofoo

Note: a first problem in the source is that $ is checked and processed before a previous \ (function find_map_unquote in read.c).


$ make --version ; echo ------------------ ; cat escape-dollar.mk ; echo ------------------ ;  make -k -f escape-dollar.mk
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
------------------
foo=foofoo
qux=qux$(foo)qux
bar=bar\$(foo)bar
baz=baz\\$(foo)baz
all:
@echo  "foo=$(foo)"
@echo  "qux=$(qux)"
@echo  "bar=$(bar)"
@echo  "baz=$(baz)"

------------------
foo=foofoo
qux=quxfoofooqux
bar=bar oofoobar
baz=baz oofoobaz


Pascal J. Bourguignon <informatimago>

 

(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 informatimago (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
    2023-04-26 psmith StatusNone Not A Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code