Skip to content

Commit 5ba421c

Browse files
committed
Fix some warnings pointed out by shellcheck
- Use `sed regex file` instead of `cat file | sed regex` - Quote more variables - Single quote `-?` to avoid bash interpreting it as - (dash) followed by any other single character - `TARBALL_PREFIX` was unused; use it
1 parent 561d6ea commit 5ba421c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

smoke-test.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ VERSION_PREFIX=5.0
77
# See https://github.com/dotnet/source-build/issues/579, this version
88
# needs to be compatible with the runtime produced from source-build
99
DEV_CERTS_VERSION_DEFAULT=5.0.0-preview.3
10-
__ROOT_REPO=$(cat "$SCRIPT_ROOT/artifacts/obj/rootrepo.txt" | sed 's/\r$//') # remove CR if mounted repo on Windows drive
10+
__ROOT_REPO=$(sed 's/\r$//' "$SCRIPT_ROOT/artifacts/obj/rootrepo.txt") # remove CR if mounted repo on Windows drive
1111
executingUserHome=${HOME:-}
1212

1313
echo "RID to test: ${targetRid?not specified. Use ./build.sh --run-smoke-test to detect RID, or specify manually.}"
@@ -91,9 +91,9 @@ while :; do
9191
break
9292
fi
9393

94-
lowerI="$(echo $1 | awk '{print tolower($0)}')"
94+
lowerI="$(echo "$1" | awk '{print tolower($0)}')"
9595
case $lowerI in
96-
-?|-h|--help)
96+
'-?'|-h|--help)
9797
usage
9898
exit 0
9999
;;
@@ -215,7 +215,7 @@ function doCommand() {
215215
elif [[ "$1" == "run" && "$proj" =~ ^(web|mvc|webapi|razor|blazorwasm|blazorserver)$ ]]; then
216216
# A separate log file that we will over-write all the time.
217217
exitLogFile="$testingDir/exitLogFile"
218-
echo > $exitLogFile
218+
echo > "$exitLogFile"
219219
# Run an application in the background and redirect its
220220
# stdout+stderr to a separate process (tee). The tee process
221221
# writes its input to 2 files:
@@ -245,7 +245,7 @@ function doCommand() {
245245
elif [ "$1" == "multi-rid-publish" ]; then
246246
runPublishScenarios() {
247247
"${dotnetCmd}" publish --self-contained false /bl:"${binlogPrefix}publish-fx-dep.binlog"
248-
"${dotnetCmd}" publish --self-contained true -r $targetRid /bl:"${binlogPrefix}publish-self-contained-${targetRid}.binlog"
248+
"${dotnetCmd}" publish --self-contained true -r "$targetRid" /bl:"${binlogPrefix}publish-self-contained-${targetRid}.binlog"
249249
"${dotnetCmd}" publish --self-contained true -r linux-x64 /bl:"${binlogPrefix}publish-self-contained-portable.binlog"
250250
}
251251
if [ "$projectOutput" == "true" ]; then
@@ -396,7 +396,7 @@ echo "<Project />" | tee Directory.Build.props > Directory.Build.targets
396396
# Unzip dotnet if the dotnetDir is not specified
397397
if [ "$dotnetDir" == "" ]; then
398398
OUTPUT_DIR="$SCRIPT_ROOT/artifacts/$buildArch/$configuration/"
399-
DOTNET_TARBALL="$(ls ${OUTPUT_DIR}dotnet-sdk-${VERSION_PREFIX}*)"
399+
DOTNET_TARBALL="$(ls "${OUTPUT_DIR}${TARBALL_PREFIX}${VERSION_PREFIX}"*)"
400400

401401
mkdir -p "$cliDir"
402402
tar xzf "$DOTNET_TARBALL" -C "$cliDir"
@@ -415,7 +415,7 @@ export NUGET_PACKAGES="$restoredPackagesDir"
415415
SOURCE_BUILT_PKGS_PATH="$SCRIPT_ROOT/artifacts/obj/$buildArch/$configuration/blob-feed/packages/"
416416
export DOTNET_ROOT="$dotnetDir"
417417
# OSX also requires DOTNET_ROOT to be on the PATH
418-
if [ `uname` == 'Darwin' ]; then
418+
if [ "$(uname)" == 'Darwin' ]; then
419419
export PATH="$dotnetDir:$PATH"
420420
fi
421421

0 commit comments

Comments
 (0)