bugmake - Bugs: bug #60799, Parser chokes on second expansion...

 
 

bug #60799: Parser chokes on second expansion of a prerequisite with ; o #

Submitter:  Dmitry Goncharov <dgoncharov>
Submitted:  Sat 19 Jun 2021 01:41:58 PM UTC
   
 
Severity:  3 - Normal Item Group:  Enhancement
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  None Operating System:  None
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 13 Dec 2021 02:37:44 PM UTC, comment #6: 

I understand what you're saying.  There's always a trade-off between having things "just work" which often involves adding a lot of exceptions and special cases, versus keeping behavior consistent and simple but forcing people to take extra steps on their own.

In general the more complex that underlying behavior the more I like to keep things consistent and simple and avoid special cases.

But, maybe this is a situation where the confusion of the simple behavior warrants adding a special case.

Paul D. Smith <psmith>
Group administrator
Thu 25 Nov 2021 06:19:37 PM UTC, comment #5: 


> But my point is that $$ is NOT (intended to be) special to make.  That's why make doesn't do parentheses matching which it sees it.


Sure, we can adopt this stance and say no parentheses matching for $$. i am not sure this behavior is the most useful make can offer.

Do you think this behavior is consistent from the user's point of view?

This works fine

.SECONDEXPANSION:
hello: $$(shell echo world); touch $@


This does not work

.SECONDEXPANSION:
hello: $$(shell echo world;); touch $@


You are right that the proposed patch adds parentheses matching and thus makes $$ special. As far as i understood, you have a concern about making $$ special?

Dmitry Goncharov <dgoncharov>
Mon 06 Sep 2021 03:08:38 PM UTC, comment #4: 

But my point is that $$ is NOT (intended to be) special to make.  That's why make doesn't do parentheses matching which it sees it.

In other words, to make this:


bye: $$(hello#world)


is treated the same way as this:


bye: D(hello#world)


for any character "D".  It's not special to make at all and so we don't do anything special with the parens either.

I don't think it's inconsistent because that's what escaping a character means: none of its special features are in force.  Personally I think it would be inconsistent to treat an escaped "$" differently than any other character.

Paul D. Smith <psmith>
Group administrator
Sat 19 Jun 2021 03:05:11 PM UTC, comment #3: 

Yes, it is possible to store special characters in a variable.

i'd not bother fixing this, if not for the fact that make already supports this input. It is just when second expansion is enabled the parser fails.

i don't think this inconsistency can be described in the manual.

This works fine
hello: $(shell echo world;)

This does not work
.SECONDEXPANSION:
hello: $$(shell echo world;)

Dmitry Goncharov <dgoncharov>
Sat 19 Jun 2021 02:22:13 PM UTC, comment #2: 

I will look at the fix but I'm not sure I want to try to work around this.  If "$$" appears in the prerequisite list then it's not special to make... this is true regardless of whether second expansion is enabled or not.

As with all special characters the best way to mask them is by hiding them in a variable:


$ cat Makefile
sem = ;
hash = \#

.SECONDEXPANSION:
all: who $$(shell echo hi 1>&2 $(sem) echo there 1>&2);@:
who: $$(shell echo 'hi $(hash) there' 1>&2);@:

$ make
hi
there
hi # there


Or of course you could put the entire thing in a variable which is even simpler/cleaner:


$ cat Makefile
sem = $(shell echo hi 1>&2 ; echo there 1>&2)
hash = $(shell echo 'hi # there' 1>&2)

.SECONDEXPANSION:

all: who $$(sem);@:
who: $$(hash);@:

$ make
hi
there
hi # there


I'll need to think about whether adding more special casing to try to recognize and manage variables/functions targeted at secondary expansion is going to cause other issues.

Paul D. Smith <psmith>
Group administrator
Sat 19 Jun 2021 01:52:02 PM UTC, comment #1: 


original submission:

> Parser chokes on second expansion of a prerequisite with ; o #
>
> $ cat makefile
> MAKEFLAGS+=--warn-undefined-variables
> .SECONDEXPANSION:
> hello: $$(shell echo world;)
>         touch $@
>
> bye: $$(hello#world)
>         touch $@
> $ make hello
> makefile:7: * unterminated variable reference.  Stop.
> $ make bye
> makefile:7: * unterminated variable reference.  Stop.
> $
>
>
> Parser treats ; as a recipe delimiter and # as a comment delimiter.


(file #51584, file #51585)

Dmitry Goncharov <dgoncharov>
Sat 19 Jun 2021 01:41:58 PM UTC, original submission:  

Parser chokes on second expansion of a prerequisite with ; o #

$ cat makefile
MAKEFLAGS+=--warn-undefined-variables
.SECONDEXPANSION:
hello: $$(shell echo world;)
        touch $@

bye: $$(hello#world)
        touch $@
$ make hello
makefile:7: * unterminated variable reference.  Stop.
$ make bye
makefile:7: * unterminated variable reference.  Stop.
$


Parser treats ; as a recipe delimiter and # as a comment delimiter.

Dmitry Goncharov <dgoncharov>

 

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

Attach Files:
   
   
Comment:
   

Attached Files

 

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 dgoncharov (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-08 psmith Item GroupNone Enhancement
    2021-06-19 dgoncharov Attached File- Added sv_60799_se_semi_fix.diff, #51584
        Attached File- Added sv_60799_se_semi_test.diff, #51585

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code