From c1b1e569e87e28d54bc19766082bab6b04e4da96 Mon Sep 17 00:00:00 2001 From: Advait Patel Date: Thu, 20 Feb 2025 01:11:18 -0600 Subject: [PATCH] Fix Unsafe Command Expansion in build-tplprev.sh The script uses `cd $(git rev-parse --show-toplevel)`, which fails if the path has spaces. Therefore, replaced `cd $(command)` with `cd "$(command)"` to properly handle spaces. After these changes. it prevents build failures due to incorrect path handling and improves error reporting too. --- scripts/build-tplprev.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/build-tplprev.sh b/scripts/build-tplprev.sh index 293710c5b..a44953f64 100755 --- a/scripts/build-tplprev.sh +++ b/scripts/build-tplprev.sh @@ -1,7 +1,16 @@ #!/bin/bash -cd $(git rev-parse --show-toplevel) +# get the repo root directory safely +REPO_ROOT="$(git rev-parse --show-toplevel)" +cd "$REPO_ROOT" || { echo "Error: Failed to change directory"; exit 1; } cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./docs/assets/ -GOARCH=wasm GOOS=js go build -o ./docs/assets/tplprev.wasm ./tplprev \ No newline at end of file +# build webassembly binary +GOARCH=wasm GOOS=js go build -o ./docs/assets/tplprev.wasm ./tplprev +if [ $? -ne 0 ]; then + echo "Error: WASM build failed!" + exit 1 +fi + +echo "WASM build successful!" \ No newline at end of file