@@ -10,7 +10,7 @@ RESET="\033[0m"
1010RED=" \033[0;31m"
1111MAGENTA=" \033[0;95m"
1212DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
13- [ -z " ${DOTNET_HOME:- } " ] && DOTNET_HOME=" $HOME /.dotnet"
13+ [ -z " ${DOTNET_HOME:- } " ] && DOTNET_HOME=" $HOME /.dotnet"
1414config_file=" $DIR /version.xml"
1515verbose=false
1616update=false
@@ -22,7 +22,7 @@ tools_source=''
2222# Functions
2323#
2424__usage (){
25- echo " Usage: $( basename ${BASH_SOURCE[0]} ) [options] [[--] <MSBUILD_ARG>...]"
25+ echo " Usage: $( basename " ${BASH_SOURCE[0]} " ) [options] [[--] <MSBUILD_ARG>...]"
2626echo " "
2727echo " Arguments:"
2828echo " <MSBUILD_ARG>... Arguments passed to MSBuild. Variable number of arguments allowed."
@@ -46,16 +46,17 @@ __usage(){
4646}
4747
4848get_korebuild (){
49+ local version
4950local lock_file=" $repo_path /korebuild-lock.txt"
50- if [ ! -f $lock_file ] || [ " $update " = true ]; then
51- __get_remote_file " $tools_source /korebuild/channels/$channel /latest.txt" $lock_file
51+ if [ ! -f " $lock_file " ] || [ " $update " = true ]; then
52+ __get_remote_file " $tools_source /korebuild/channels/$channel /latest.txt" " $lock_file "
5253fi
53- local version=" $( grep ' version:*' -m 1 $lock_file ) "
54+ version=" $( grep ' version:*' -m 1 " $lock_file " ) "
5455if [[ " $version " == ' ' ]]; then
5556 __error " Failed to parse version from $lock_file . Expected a line that begins with 'version:'"
5657return 1
5758fi
58- version=" $( echo ${version# version: } | sed -e ' s/^[[:space:]]*//' -e ' s/[[:space:]]*$//' ) "
59+ version=" $( echo " ${version# version: } " | sed -e ' s/^[[:space:]]*//' -e ' s/[[:space:]]*$//' ) "
5960local korebuild_path=" $DOTNET_HOME /buildtools/korebuild/$version "
6061
6162{
@@ -64,10 +65,10 @@ get_korebuild(){
6465local remote_path=" $tools_source /korebuild/artifacts/$version /korebuild.$version .zip"
6566 tmpfile=" $( mktemp) "
6667echo -e " ${MAGENTA} Downloading KoreBuild ${version}${RESET} "
67- if __get_remote_file $remote_path $tmpfile ; then
68- unzip -q -d " $korebuild_path " $tmpfile
68+ if __get_remote_file " $remote_path " " $tmpfile " ; then
69+ unzip -q -d " $korebuild_path " " $tmpfile "
6970fi
70- rm $tmpfile || true
71+ rm " $tmpfile " || true
7172fi
7273
7374source " $korebuild_path /KoreBuild.sh"
@@ -81,7 +82,7 @@ get_korebuild(){
8182}
8283
8384__error (){
84- echo -e " ${RED} $@ ${RESET} " 1>&2
85+ echo -e " ${RED} $* ${RESET} " 1>&2
8586}
8687
8788__machine_has (){
@@ -94,18 +95,18 @@ __get_remote_file(){
9495local local_path=$2
9596
9697if [[ " $remote_path " != ' http' * ]]; then
97- cp $remote_path $local_path
98+ cp " $remote_path " " $local_path "
9899return 0
99100fi
100101
101102 failed=false
102103if __machine_has wget; then
103- wget --tries 10 --quiet -O $local_path $remote_path || failed=true
104+ wget --tries 10 --quiet -O " $local_path " " $remote_path " || failed=true
104105fi
105106
106107if [ " $failed " = true ] && __machine_has curl; then
107108 failed=false
108- curl --retry 10 -sSL -f --create-dirs -o $local_path $remote_path || failed=true
109+ curl --retry 10 -sSL -f --create-dirs -o " $local_path " " $remote_path " || failed=true
109110fi
110111
111112if [ " $failed " = true ]; then
@@ -114,21 +115,21 @@ __get_remote_file(){
114115fi
115116}
116117
117- __read_dom (){local IFS=\> ; read -d \< ENTITY CONTENT ; }
118+ __read_dom (){local IFS=\> ; read -r - d \< ENTITY CONTENT ; }
118119
119120#
120121# main
121122#
122123
123- while [[ $# > 0 ]]; do
124+ while [[ $# -gt 0 ]]; do
124125case $1 in
125126 -\? |-h|--help)
126127 __usage --no-exit
127128exit 0
128129 ;
129130 -c|--channel|-Channel)
130131shift
131- channel=${1:- }
132+ channel=" ${1:- } "
132133 [ -z " $channel " ] && __usage
133134 ;
134135 --config-file|-ConfigFile)
@@ -138,7 +139,7 @@ while [[ $# > 0 ]]; do
138139 ;
139140 -d|--dotnet-home|-DotNetHome)
140141shift
141- DOTNET_HOME=${1:- }
142+ DOTNET_HOME=" ${1:- } "
142143 [ -z " $DOTNET_HOME " ] && __usage
143144 ;
144145 --path|-Path)
@@ -178,19 +179,19 @@ if ! __machine_has curl && ! __machine_has wget; then
178179exit 1
179180fi
180181
181- if [ -f $config_file ]; then
182+ if [ -f " $config_file " ]; then
182183 comment=false
183184while __read_dom; do
184185if [ " $comment " = true ]; then [[ $CONTENT == * ' -->' * ]] && comment=false ; continue ; fi
185186if [[ $ENTITY == ' !--' * ]]; then comment=true; continue ; fi
186187if [ -z " $channel " ] && [[ $ENTITY == " KoreBuildChannel" ]]; then channel=$CONTENT ; fi
187188if [ -z " $tools_source " ] && [[ $ENTITY == " KoreBuildToolsSource" ]]; then tools_source=$CONTENT ; fi
188- done < $config_file
189+ done < " $config_file "
189190fi
190191
191192[ -z " $channel " ] && channel=' dev'
192193[ -z " $tools_source " ] && tools_source=' https://aspnetcore.blob.core.windows.net/buildtools'
193194
194195get_korebuild
195196install_tools " $tools_source " " $DOTNET_HOME "
196- invoke_repository_build " $repo_path " $@
197+ invoke_repository_build " $repo_path " " $@ "
0 commit comments