From e6d7bdca1d2bb0fb752ccfac2882f32a2a61d088 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <15055071+Machine-Maker@users.noreply.github.com> Date: Thu, 19 Nov 2020 07:47:22 -0800 Subject: [PATCH] [CI-SKIP] fixed sed -i for bsd sed (#4782) --- scripts/init.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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"