gradlew-fdroid: fix parsing when files have Windows linefeeds

The new test file should have Windows linefeeds, if I got the git config
correct.
This commit is contained in:
Hans-Christoph Steiner 2020-05-29 21:55:10 +02:00
parent fc885c9b5c
commit 7a84679b0d
3 changed files with 14 additions and 0 deletions

View file

@ -168,6 +168,7 @@ for f in {.,..}/gradle/wrapper/gradle-wrapper.properties; do
if [[ $line == 'distributionUrl='* ]]; then
wrapper_ver=${line#*/gradle-}
wrapper_ver=${wrapper_ver%-*.zip}
wrapper_ver=$(printf $wrapper_ver | tr -d '\r') # strip Windows linefeeds
break 2
fi
done < $f
@ -186,9 +187,11 @@ for f in {.,..}/build.gradle{,.kts}; do
if [[ -z "$plugin_pver" && $line == *'com.android.tools.build:gradle:'* ]]; then
plugin_pver=${line#*[\'\"]com.android.tools.build:gradle:}
plugin_pver=${plugin_pver%[\'\"]*}
plugin_pver=$(printf $plugin_pver | tr -d '\r') # strip Windows linefeeds
elif [[ -z "$wrapper_ver" && $line == *'gradleVersion = '* ]]; then
wrapper_ver=${line#*gradleVersion*=*[\'\"]}
wrapper_ver=${wrapper_ver%[\'\"]*}
wrapper_ver=$(printf $wrapper_ver | tr -d '\r') # strip Windows linefeeds
fi
done < $f
done