aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2020-11-19 07:47:22 -0800
committerGitHub <[email protected]>2020-11-19 10:47:22 -0500
commite6d7bdca1d2bb0fb752ccfac2882f32a2a61d088 (patch)
tree4d39fbcce8e7f003a4b2127f72b7186ca4adcc31 /scripts
parent7ae47d4eb33fd7b2baf6c80a95afa4ff1c1d15e3 (diff)
downloadPaper-e6d7bdca1d2bb0fb752ccfac2882f32a2a61d088.tar.gz
Paper-e6d7bdca1d2bb0fb752ccfac2882f32a2a61d088.zip
[CI-SKIP] fixed sed -i for bsd sed (#4782)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/init.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/scripts/init.sh b/scripts/init.sh
index 25aa24bcf7..3b85343d6c 100755
--- a/scripts/init.sh
+++ b/scripts/init.sh
@@ -11,6 +11,18 @@ nms="$spigotdecompiledir/net/minecraft/server"
cb="src/main/java/net/minecraft/server"
gitcmd="git -c commit.gpgsign=false"
+# https://stackoverflow.com/a/38595160
+# https://stackoverflow.com/a/800644
+if sed --version >/dev/null 2>&1; then
+ strip_cr() {
+ sed -i -- "s/\r//" "$@"
+ }
+else
+ strip_cr () {
+ sed -i "" "s/$(printf '\r')//" "$@"
+ }
+fi
+
patch=$(which patch 2>/dev/null)
if [ "x$patch" == "x" ]; then
patch="$basedir/hctap.exe"
@@ -53,7 +65,7 @@ do
echo "Patching $file < $patchFile"
set +e
- sed -i 's/\r//' "$nms/$file" > /dev/null
+ strip_cr "$nms/$file" > /dev/null
set -e
"$patch" -s -d src/main/java/ "net/minecraft/server/$file" < "$patchFile"