bugmake - Bugs: bug #55719, Variables containing hyphens are...

 
 

bug #55719: Variables containing hyphens are not exported

Submitter:  Masahiro Yamada <masahiroy>
Submitted:  Sat 16 Feb 2019 09:29:01 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  None Operating System:  Any
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 13 May 2019 09:53:54 PM UTC, comment #1: 

The variable "foo-bar" is exported by make to the recipe that it invokes, in all situations.

However, in the situation where a shell is invoked, the shell disallows variables which don't meet its naming criteria.

There's nothing make can do about that.  The only way to make this consistent would be to change export so that it won't export any variable that doesn't meet the shell's naming criteria.  Maybe we should do that.  However, we should only do this if the shell we're invoking is a POSIX-ish shell since makefiles could choose a different interpreter for the shell, which CAN support environment variables that don't match the shell's requirements.

Paul D. Smith <psmith>
Group administrator
Sat 16 Feb 2019 09:29:01 AM UTC, original submission:  

Shell cannot cope with variable names consisting of characters
other than letters, numbers, and underscores.

Make allows more characters in variable names,
such as a hyphen.

The variables are exported to sub-make
by using the 'export' directive.

For example, 'export foo-bar'
will export the variable 'foo-bar' to sub-make.

However, it does not work under some circumstances.

I attached two test-cases.


Makefile1 exports 'foo-bar' to sub-make.

If you run Makefile2 on Ubuntu, where /bin/sh is a
symlink to dash, 'foo-bar' is not exported to sub-make.


$ make -f Makefile1
make sub_make=1
foo-bar: 1
foo_bar: 2
$ make -f Makefile2
make sub_make=~
foo-bar:
foo_bar: 2


I think this difference comes from
the reluctance of spawning a sub-shell.


In Makefile1, Make will directly execute
'$(MAKE) sub_make=1' without spawning a sub-shell.

In Makefile2, Make will execute
'$(MAKE) sub_make=~' in a sub-shell since '~' is a shell special character.

Masahiro Yamada <masahiroy>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #46276:  Makefile1 added by masahiroy (213B - application/octet-stream)
file #46277:  Makefile2 added by masahiroy (213B - application/octet-stream)

 

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 masahiroy (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-05-13 psmith StatusNone Not A Bug
        Open/ClosedOpen Closed
    2019-02-16 masahiroy Attached File- Added Makefile1, #46276
        Attached File- Added Makefile2, #46277

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code