Skip to content
This repository was archived by the owner on Nov 6, 2018. It is now read-only.

Commit dd44712

Browse files
author
Nate McMaster
committed
Fix syntax warning when running build.sh on older versions of bash
[ci skip]
1 parent 5ce326a commit dd44712

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

build.sh

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RESET="\033[0m"
1010
RED="\033[0;31m"
1111
MAGENTA="\033[0;95m"
1212
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
13-
[ -z "${DOTNET_HOME:-}"] && DOTNET_HOME="$HOME/.dotnet"
13+
[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet"
1414
config_file="$DIR/version.xml"
1515
verbose=false
1616
update=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>...]"
2626
echo ""
2727
echo "Arguments:"
2828
echo " <MSBUILD_ARG>... Arguments passed to MSBuild. Variable number of arguments allowed."
@@ -46,16 +46,17 @@ __usage() {
4646
}
4747

4848
get_korebuild() {
49+
local version
4950
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"
5253
fi
53-
local version="$(grep 'version:*' -m 1 $lock_file)"
54+
version="$(grep 'version:*' -m 1 "$lock_file")"
5455
if [[ "$version" == '' ]]; then
5556
__error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'"
5657
return 1
5758
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:]]*$//')"
5960
local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version"
6061

6162
{
@@ -64,10 +65,10 @@ get_korebuild() {
6465
local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip"
6566
tmpfile="$(mktemp)"
6667
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"
6970
fi
70-
rm $tmpfile || true
71+
rm "$tmpfile" || true
7172
fi
7273

7374
source "$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() {
9495
local local_path=$2
9596

9697
if [[ "$remote_path" != 'http'* ]]; then
97-
cp $remote_path $local_path
98+
cp "$remote_path" "$local_path"
9899
return 0
99100
fi
100101

101102
failed=false
102103
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
104105
fi
105106

106107
if [ "$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
109110
fi
110111

111112
if [ "$failed" = true ]; then
@@ -114,21 +115,21 @@ __get_remote_file() {
114115
fi
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
124125
case $1 in
125126
-\?|-h|--help)
126127
__usage --no-exit
127128
exit 0
128129
;;
129130
-c|--channel|-Channel)
130131
shift
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)
140141
shift
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
178179
exit 1
179180
fi
180181

181-
if [ -f $config_file ]; then
182+
if [ -f "$config_file" ]; then
182183
comment=false
183184
while __read_dom; do
184185
if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi
185186
if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi
186187
if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi
187188
if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi
188-
done < $config_file
189+
done < "$config_file"
189190
fi
190191

191192
[ -z "$channel" ] && channel='dev'
192193
[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools'
193194

194195
get_korebuild
195196
install_tools "$tools_source" "$DOTNET_HOME"
196-
invoke_repository_build "$repo_path" $@
197+
invoke_repository_build "$repo_path" "$@"

0 commit comments

Comments
 (0)