Skip to content

Commit 71686a2

Browse files
committed
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
1 parent 07992b8 commit 71686a2

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

scripts/fmt.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
cd "$(dirname "$0")/../rust"
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
6+
cd "$REPO_ROOT/rust"
57
exec cargo fmt "$@"

0 commit comments

Comments
 (0)