Skip to content

Commit c1b1e56

Browse files
committed
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.
1 parent 76f9cea commit c1b1e56

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

scripts/build-tplprev.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
#!/bin/bash
22

3-
cd $(git rev-parse --show-toplevel)
3+
# get the repo root directory safely
4+
REPO_ROOT="$(git rev-parse --show-toplevel)"
5+
cd "$REPO_ROOT" || { echo "Error: Failed to change directory"; exit 1; }
46

57
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./docs/assets/
68

7-
GOARCH=wasm GOOS=js go build -o ./docs/assets/tplprev.wasm ./tplprev
9+
# build webassembly binary
10+
GOARCH=wasm GOOS=js go build -o ./docs/assets/tplprev.wasm ./tplprev
11+
if [ $? -ne 0 ]; then
12+
echo "Error: WASM build failed!"
13+
exit 1
14+
fi
15+
16+
echo "WASM build successful!"

0 commit comments

Comments
 (0)