aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/assembly
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2017-02-22 14:05:05 +0100
committerDuarte Meneses <duarte.meneses@sonarsource.com>2017-02-22 15:48:05 +0100
commit0c5295ed0ed729f84acd0df6971593d30056af1e (patch)
treeab79f5ec4465837784a9a1175fc642f24e7b0221 /src/main/assembly
parent39be5c0b9d7c1c0fcc36ad4f9e5d89ff8606357b (diff)
downloadsonar-scanner-cli-0c5295ed0ed729f84acd0df6971593d30056af1e.tar.gz
sonar-scanner-cli-0c5295ed0ed729f84acd0df6971593d30056af1e.zip
SQSCANNER-35 Fix script home detection and path quoting issues
Diffstat (limited to 'src/main/assembly')
-rwxr-xr-xsrc/main/assembly/bin/sonar-runner46
-rwxr-xr-xsrc/main/assembly/bin/sonar-scanner46
2 files changed, 26 insertions, 66 deletions
diff --git a/src/main/assembly/bin/sonar-runner b/src/main/assembly/bin/sonar-runner
index 313a745..a02252d 100755
--- a/src/main/assembly/bin/sonar-runner
+++ b/src/main/assembly/bin/sonar-runner
@@ -34,35 +34,19 @@
# authors and should not be interpreted as representing official policies, either expressed
# or implied, of Jon Disnard.
real_path () {
- OIFS=$IFS
- IFS='/'
- for I in $1
- do
- # Resolve relative path punctuation.
- if [ "$I" = "." ] || [ -z "$I" ]
- then continue
- elif [ "$I" = ".." ]
- then FOO="${FOO%%/${FOO##*/}}"
- continue
- else FOO="${FOO}/${I}"
- fi
+ target=$1
- # Dereference symbolic links.
- if [ -h "$FOO" ] && [ -x "/bin/ls" ]
- then IFS=$OIFS
- set `/bin/ls -l "$FOO"`
- while shift ;
- do
- if [ "$1" = "->" ]
- then FOO=$2
- shift $#
- break
- fi
- done
- fi
+ (
+ while true; do
+ cd "$(dirname "$target")"
+ target=$(basename "$target")
+ link=$(readlink "$target")
+ test "$link" || break
+ target=$link
done
- IFS=$OIFS
- echo "$FOO"
+
+ echo "$(pwd -P)/$target"
+ )
}
echo WARN: 'sonar-runner' script is deprecated. Please use 'sonar-scanner' instead.
@@ -71,11 +55,7 @@ script_path="$0"
if [ -h "$script_path" ] ; then
# resolve recursively symlinks
- r_script_path=$(real_path "$script_path")
- until [ "$R_script_path" = "$script_path" ]; do
- script_path="$R_script_path"
- r_script_path=$(real_path "$script_path")
- done
+ script_path=$(real_path "$script_path")
fi
sonar_runner_home=$(dirname "$script_path")/..
@@ -115,7 +95,7 @@ project_home=$(pwd)
exec "$java_cmd" \
-Djava.awt.headless=true \
$SONAR_SCANNER_OPTS \
- -classpath $jar_file \
+ -classpath "$jar_file" \
-Dscanner.home=\$sonar_runner_home \
-Dproject.home=\$project_home \
org.sonarsource.scanner.cli.Main "$@"
diff --git a/src/main/assembly/bin/sonar-scanner b/src/main/assembly/bin/sonar-scanner
index 6b54cc9..93e99d9 100755
--- a/src/main/assembly/bin/sonar-scanner
+++ b/src/main/assembly/bin/sonar-scanner
@@ -35,46 +35,26 @@
# authors and should not be interpreted as representing official policies, either expressed
# or implied, of Jon Disnard.
real_path () {
- OIFS=$IFS
- IFS='/'
- for I in $1
- do
- # Resolve relative path punctuation.
- if [ "$I" = "." ] || [ -z "$I" ]
- then continue
- elif [ "$I" = ".." ]
- then FOO="${FOO%%/${FOO##*/}}"
- continue
- else FOO="${FOO}/${I}"
- fi
+ target=$1
- # Dereference symbolic links.
- if [ -h "$FOO" ] && [ -x "/bin/ls" ]
- then IFS=$OIFS
- set `/bin/ls -l "$FOO"`
- while shift ;
- do
- if [ "$1" = "->" ]
- then FOO=$2
- shift $#
- break
- fi
- done
- fi
+ (
+ while true; do
+ cd "$(dirname "$target")"
+ target=$(basename "$target")
+ link=$(readlink "$target")
+ test "$link" || break
+ target=$link
done
- IFS=$OIFS
- echo "$FOO"
+
+ echo "$(pwd -P)/$target"
+ )
}
script_path="$0"
if [ -h "$script_path" ] ; then
# resolve recursively symlinks
- r_script_path=$(real_path "$script_path")
- until [ "$r_script_path" = "$script_path" ]; do
- script_path="$r_script_path"
- r_script_path=`real_path "$script_path"`
- done
+ script_path=$(real_path "$script_path")
fi
sonar_scanner_home=$(dirname "$script_path")/..
@@ -107,7 +87,7 @@ exec "$java_cmd" \
-Djava.awt.headless=true \
$SONAR_SCANNER_OPTS \
$SONAR_SCANNER_DEBUG_OPTS \
- -classpath $jar_file \
+ -classpath "$jar_file" \
-Dscanner.home=\$sonar_scanner_home \
-Dproject.home=\$project_home \
org.sonarsource.scanner.cli.Main "$@"