Skip to content

Commit 1511100

Browse files
authored
Merge pull request #234 from davidy4ng/fix/shell-script-filename-with-spaces
fix: read parameter from sonar-project.properties safely with spaces
2 parents 844da3c + a346ba5 commit 1511100

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sonar-swift-plugin/src/main/shell/run-sonar-swift.sh

100755100644
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function readParameter() {
6363
parameter=$1
6464
shift
6565

66-
eval $variable="\"$(sed '/^\#/d' sonar-project.properties | grep $parameter | tail -n 1 | cut -d '=' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')\""
66+
eval $variable=$(printf %q "$(sed '/^\#/d' sonar-project.properties | grep $parameter | tail -n 1 | cut -d '=' -f2-)")
6767
}
6868

6969
# Run a set of commands with logging and error handling
@@ -277,13 +277,14 @@ rm -rf sonar-reports
277277
mkdir sonar-reports
278278

279279
# Extracting project information needed later
280+
buildCmd=($XCODEBUILD_CMD clean build)
280281
echo -n 'Extracting Xcode project information'
281282
if [[ "$workspaceFile" != "" ]] ; then
282-
buildCmdPrefix="-workspace $workspaceFile"
283+
buildCmd+=(-workspace "$workspaceFile")
283284
else
284-
buildCmdPrefix="-project $projectFile"
285+
buildCmd+=(-project "$projectFile")
285286
fi
286-
buildCmd=($XCODEBUILD_CMD clean build $buildCmdPrefix -scheme $appScheme)
287+
buildCmd+=(-scheme $appScheme)
287288
if [[ ! -z "$destinationSimulator" ]]; then
288289
buildCmd+=(-destination "$destinationSimulator" -destination-timeout 360 COMPILER_INDEX_STORE_ENABLE=NO)
289290
fi

0 commit comments

Comments
 (0)