From 71686a20fcff54cd6f6e9ceeef091b5956f30e12 Mon Sep 17 00:00:00 2001 From: Yeachan-Heo Date: Tue, 28 Apr 2026 09:38:40 +0000 Subject: [PATCH] Resolve fmt wrapper path from its own directory The formatting wrapper should remain safe when invoked through different current directories or shell contexts, so resolve the script directory before entering the Rust workspace and forwarding cargo fmt arguments. Constraint: Wrapper must be runnable from repo root while forwarding flags like --check Rejected: Leave relative dirname cd | less robust if invocation context changes Confidence: high Scope-risk: narrow Tested: scripts/fmt.sh --check Tested: git diff --check --- scripts/fmt.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/fmt.sh b/scripts/fmt.sh index e46e46e..83d9762 100755 --- a/scripts/fmt.sh +++ b/scripts/fmt.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -cd "$(dirname "$0")/../rust" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +cd "$REPO_ROOT/rust" exec cargo fmt "$@"