@@ -10,7 +10,7 @@ RESET="\033[0m"
10
10
RED=" \033[0;31m"
11
11
MAGENTA=" \033[0;95m"
12
12
DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
13
- [ -z " ${DOTNET_HOME:- } " ] && DOTNET_HOME=" $HOME /.dotnet"
13
+ [ -z " ${DOTNET_HOME:- } " ] && DOTNET_HOME=" $HOME /.dotnet"
14
14
config_file=" $DIR /version.xml"
15
15
verbose=false
16
16
update=false
@@ -22,7 +22,7 @@ tools_source=''
22
22
# Functions
23
23
#
24
24
__usage () {
25
- echo " Usage: $( basename ${BASH_SOURCE[0]} ) [options] [[--] <MSBUILD_ARG>...]"
25
+ echo " Usage: $( basename " ${BASH_SOURCE[0]} " ) [options] [[--] <MSBUILD_ARG>...]"
26
26
echo " "
27
27
echo " Arguments:"
28
28
echo " <MSBUILD_ARG>... Arguments passed to MSBuild. Variable number of arguments allowed."
@@ -46,16 +46,17 @@ __usage() {
46
46
}
47
47
48
48
get_korebuild () {
49
+ local version
49
50
local 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 "
52
53
fi
53
- local version=" $( grep ' version:*' -m 1 $lock_file ) "
54
+ version=" $( grep ' version:*' -m 1 " $lock_file " ) "
54
55
if [[ " $version " == ' ' ]]; then
55
56
__error " Failed to parse version from $lock_file . Expected a line that begins with 'version:'"
56
57
return 1
57
58
fi
58
- version=" $( echo ${version# version: } | sed -e ' s/^[[:space:]]*//' -e ' s/[[:space:]]*$//' ) "
59
+ version=" $( echo " ${version# version: } " | sed -e ' s/^[[:space:]]*//' -e ' s/[[:space:]]*$//' ) "
59
60
local korebuild_path=" $DOTNET_HOME /buildtools/korebuild/$version "
60
61
61
62
{
@@ -64,10 +65,10 @@ get_korebuild() {
64
65
local remote_path=" $tools_source /korebuild/artifacts/$version /korebuild.$version .zip"
65
66
tmpfile=" $( mktemp) "
66
67
echo -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 "
69
70
fi
70
- rm $tmpfile || true
71
+ rm " $tmpfile " || true
71
72
fi
72
73
73
74
source " $korebuild_path /KoreBuild.sh"
@@ -81,7 +82,7 @@ get_korebuild() {
81
82
}
82
83
83
84
__error () {
84
- echo -e " ${RED} $@ ${RESET} " 1>&2
85
+ echo -e " ${RED} $* ${RESET} " 1>&2
85
86
}
86
87
87
88
__machine_has () {
@@ -94,18 +95,18 @@ __get_remote_file() {
94
95
local local_path=$2
95
96
96
97
if [[ " $remote_path " != ' http' * ]]; then
97
- cp $remote_path $local_path
98
+ cp " $remote_path " " $local_path "
98
99
return 0
99
100
fi
100
101
101
102
failed=false
102
103
if __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
104
105
fi
105
106
106
107
if [ " $failed " = true ] && __machine_has curl; then
107
108
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
109
110
fi
110
111
111
112
if [ " $failed " = true ]; then
@@ -114,21 +115,21 @@ __get_remote_file() {
114
115
fi
115
116
}
116
117
117
- __read_dom () { local IFS=\> ; read -d \< ENTITY CONTENT ; }
118
+ __read_dom () { local IFS=\> ; read -r - d \< ENTITY CONTENT ; }
118
119
119
120
#
120
121
# main
121
122
#
122
123
123
- while [[ $# > 0 ]]; do
124
+ while [[ $# -gt 0 ]]; do
124
125
case $1 in
125
126
-\? |-h|--help)
126
127
__usage --no-exit
127
128
exit 0
128
129
;;
129
130
-c|--channel|-Channel)
130
131
shift
131
- channel=${1:- }
132
+ channel=" ${1:- } "
132
133
[ -z " $channel " ] && __usage
133
134
;;
134
135
--config-file|-ConfigFile)
@@ -138,7 +139,7 @@ while [[ $# > 0 ]]; do
138
139
;;
139
140
-d|--dotnet-home|-DotNetHome)
140
141
shift
141
- DOTNET_HOME=${1:- }
142
+ DOTNET_HOME=" ${1:- } "
142
143
[ -z " $DOTNET_HOME " ] && __usage
143
144
;;
144
145
--path|-Path)
@@ -178,19 +179,19 @@ if ! __machine_has curl && ! __machine_has wget; then
178
179
exit 1
179
180
fi
180
181
181
- if [ -f $config_file ]; then
182
+ if [ -f " $config_file " ]; then
182
183
comment=false
183
184
while __read_dom; do
184
185
if [ " $comment " = true ]; then [[ $CONTENT == * ' -->' * ]] && comment=false ; continue ; fi
185
186
if [[ $ENTITY == ' !--' * ]]; then comment=true; continue ; fi
186
187
if [ -z " $channel " ] && [[ $ENTITY == " KoreBuildChannel" ]]; then channel=$CONTENT ; fi
187
188
if [ -z " $tools_source " ] && [[ $ENTITY == " KoreBuildToolsSource" ]]; then tools_source=$CONTENT ; fi
188
- done < $config_file
189
+ done < " $config_file "
189
190
fi
190
191
191
192
[ -z " $channel " ] && channel=' dev'
192
193
[ -z " $tools_source " ] && tools_source=' https://aspnetcore.blob.core.windows.net/buildtools'
193
194
194
195
get_korebuild
195
196
install_tools " $tools_source " " $DOTNET_HOME "
196
- invoke_repository_build " $repo_path " $@
197
+ invoke_repository_build " $repo_path " " $@ "
0 commit comments