🌱 Make make remove-spaces
compatible with GNU and MAC OS X system
#4354
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.
Why this PR does exist
This PR is motivated by this issue: #4327.
It is a fix about the make remove-spaces command that was only working on OS X and not GNU based system. It is because the behavior of the sed -i command is different between these two systems (see this stack exchange discussion).
sed -i ''
sed -i
So I added a check by using
uname
to use thesed -i
in the correct way depending if we are on GNU based system or on OS X based system.This PR follows this one #4330 that was not working. So it got reverted here #4331. This PR should works correctly. I cannot test on a MAC since I only have a linux system.
This PR needs to be tested by someone that has a MAC before merging.
Quick explanation
The
bash -c
is used becausemake
cannot interpretif
&else
since it executes each line of the recipe in a separate shell (each command runs in isolation, making the condition ineffective).Then we check only for "Linux" system and not "Darwin". Why? Because we want the default behavior of the command to be the same as previously (the command that worked for the "Darwin" system).
Thus, if it is a GNU system (uname = Linux), then we execute the modified command. Else, we execute the default behavior -> the previous command.