sed command problem in setup.sh on MacOS
latibro opened this issue ยท 4 comments
Describe the bug
When setting up dev environment, you run setup.sh which and in some of these scripts it uses "sed" command to replace some text in some files.
The problem here is that it used the inline edit function "-i" of "sed", which work differently on Linux and MacOS.
sed command is used 2 places in https://github.com/TeamOpenIndustry/UniversalModCore/blob/forge_1.12.2/template/setup.sh and 2 places in https://github.com/TeamOpenIndustry/ImmersiveRailroadingIntegration/blob/forge_1.12.2/setup.sh
On MacOS those 4 executions of the sed command all result in "sed: -i may not be used with stdin", and no change in files.
How to reproduce
Steps to reproduce the unwanted behavior:
On MacOS
- Clone IR repo
- Execute setup.sh
- Output shows "sed: -i may not be used with stdin"
If you try to compile the code after this, you will get errors as the text in the files are not replaced.
Expected behavior
Text in files are replaces
Screenshots
n/a
System Information
OS: MacOS
System Memory: n/a
Allocated Memory: n/a
CPU: n/a
GPU: n/a
IR-Version: "1.7.4_1.12.2"]
Forge-Version: "1.12.2 - 14.23.5.2844"
Modlist
n/a
latest.log
n/a
Additional context
n/a
Some research shows that it is a know problem with sed, that i works different in Linux and MacOS.
I'm researching how to do the replace in another way, that will work on both Linux and MacOS.
Think I found a note en a commit somewhere from cam72cam, that the use of text replace (which sed is used for) was a temp solution until some better solution was found. But can't remember where I found that comment.
Seems like sed command gives more problems on MacOS ...
- the replacement string "\0" seems to be replaces with "0" instead of the original match string (easy fix is to wrap match with paratheses and use "\1" which works)
- the new line "\n" results in "n" and not at new line
Easy solution for MacOS would be to install GNU sed
brew install gnu-sed
But should be possible to do it with a solution without that :-)