Fix make shell detection - #6146
Merged
Merged
Conversation
GNU Make on Windows may use sh even when invoked from cmd. Probe how echo handles quotes instead of choosing shell syntax from the target OS. Apply this to the library, examples and tools, preserving explicit PLATFORM_SHELL overrides. Stop forcing cmd for library cleanup and fix Win32 recipe indentation.
The form FORMAT=JSON EXTENSION=json $(MAKE) parse uses sh environment assignments. Under cmd, FORMAT=JSON is treated as a command and fails. Use $(MAKE) parse FORMAT=JSON EXTENSION=json instead. This passes the variables directly to make and works under both shells.
|
For curiosity, are there any reasons to use echo "test" instead of just finding the executable? something like |
Contributor
Author
|
Actually, my blogpost is a little wrong on this point. Make DOES report sh.exe in SHELL (it's not unset), but it's not consistent. This is maybe a GNU make bug, but if you run I still think it's the correct approach for this PR. |
Contributor
Author
|
Owner
|
@Peter0x44 thanks for the review and the explanation! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6135.
The Makefiles assume Windows means cmd, but GNU Make can select sh
instead. This causes
make cleanto use the wrong shell commands.Detect the recipe shell using
echo "test": cmd preserves the quotes,while sh removes them. Apply this to the library, examples and tools,
and remove the forced cmd shell from library cleanup. Explicit
PLATFORM_SHELL overrides remain supported.
Also fix Win32 clean recipe indentation and,
pass rlparser's recursive make variables as command-line arguments
so those calls work under both cmd and sh.