bugmake - Bugs: bug #58420, PATH changes are not applied in...

 
 

bug #58420: PATH changes are not applied in $(shell) function

Submitted by:  Manoj Srivastava <srivasta>
Submitted on:  Wed 20 May 2020 11:21:52 PM UTC  
 
Severity:  3 - Normal Item Group:  Bug
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  4.3 Operating System:  None
Fixed Release:  None Triage Status:  None

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 21 May 2020 02:30:00 AM UTC, comment #2: 

$(shell) commands in a recipe... well, we've all seen it done.
 But, hang on, PATH doesn't behave specially for me:

martind@sirius:~/tmp/make-58420$ cat Makefile
NOT_PATH := /nonexistent:$(NOT_PATH)
$(shell echo during parsing NOT_PATH=$(NOT_PATH) 1>&2)

default:; @echo "make variable NOT_PATH=$(NOT_PATH)"; echo "in target commands, NOT_PATH=$$NOT_PATH"; echo "in \$$(shell commands), NOT_PATH=$(shell echo "$$NOT_PATH")"
martind@sirius:~/tmp/make-58420$ NOT_PATH=export-me make
during parsing NOT_PATH=/nonexistent:export-me
make variable NOT_PATH=/nonexistent:export-me
in target commands, NOT_PATH=/nonexistent:export-me
in $(shell commands), NOT_PATH=export-me
martind@sirius:~/tmp/make-58420$

(I put the recipe on one line because tabs often don't come out in the mail.)

Seeing:

Component Version: 4.3

I worried that it might be due to the new spawning code, but the results above, which I think are consistent with the reporter's, were from make-4.1.  I get the same from 4.0 and even 3.81.

After puzzling over the code, I belatedly realized that my "during parsing" line above isn't doing the same as the $(shell) in the recipe.  The former is passing the Make variable's value to $(shell), where the latter is getting it out of the environment given to $(shell).  The code-comment here appears likely to pertain:

http://git.savannah.gnu.org/cgit/make.git/tree/src/function.c#n1727

... which points us at:

https://savannah.gnu.org/bugs/?func=detailitem&item_id=10593

I think this is a duplicate.

Martin Dorey <mdorey>
Wed 20 May 2020 11:27:21 PM UTC, comment #1: 

I stand corrected. The actual CC should be -email is unavailable-

Manoj Srivastava <srivasta>
Wed 20 May 2020 11:21:52 PM UTC, original submission:  

This was reported by a debian user. Please retain the CC to -email is unavailable- to ensure your responses reach the reporter.

Given the following Makefile:

--- BEGIN ---
PATH := /nonexistent:$(PATH)

default:
@echo "make variable PATH=$(PATH)"
@echo "in target commands, PATH=$$PATH"
@echo "in \$$(shell commands), PATH=$(shell echo "$$PATH")"
--- END ---

'make' generates the output for me:

make variable PATH=/nonexistent:/home/ben/bin:/usr/lib/ccache:/usr/local/sbin:/usr/sbin:/sbin:/home/ben/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
in target commands, PATH=/nonexistent:/home/ben/bin:/usr/lib/ccache:/usr/local/sbin:/usr/sbin:/sbin:/home/ben/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
in $(shell commands), PATH=/home/ben/bin:/usr/lib/ccache:/usr/local/sbin:/usr/sbin:/sbin:/home/ben/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

I can't see any documentation that says the PATH variable is special, so I think this is a bug.  I would guess that make defers evaluating the PATH variable into the environment, in case it's recursively expanded, but only re-evaulates it before running target commands.

Ben.

Manoj Srivastava <srivasta>

 

(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 mdorey (Posted a comment)
  • -email is unavailable- added by srivasta (This was reported by a debian user. Please retain the CC to ensure your responses reach the reporter.)
  • -email is unavailable- added by srivasta (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-05-20 srivasta Carbon-Copy- => Added 895835-forwarded@bugs.debian.org
    2020-05-20 srivasta Carbon-CopyRemoved -email is unavailable- => -
    2020-05-20 srivasta Carbon-Copy- => Added 635646-forwarded@bugs.debian.org

    Back to the top


    Powered by Savane 3.5