Repository navigation
tools: --help finds its header by a relative path from another directory - #586
Conversation
Run by a relative path from somewhere other than the repository root (cd ..; omarchy-mobile/tools/build-packages --help, or ./release --help from tools/), the eight tools that cd to the repository before they read their options failed --help: they passed "$0", which is relative to the directory they had just left, and awk couldn't open it (exit 2). Derek pointed this out on derekross#559 and suggested usage_from_header as the place to fix it. usage_from_header now takes only FILE's name and reads that tool from the tools directory above tools/lib/usage.sh. The helper's own path is still valid when it runs, because every caller has just sourced it from its current directory, so this fixes all eight callers in one place with no call site changed. The tools that resolve their own path first (fetch-toolchain, kernel-pr-check, publish-kernel) or don't cd before --help (build-flame-probe, phone-smoke, phone-demo), and the bundle's inline-awk tools (install-phone, nv-backup, phone-provision), already worked; their files are unchanged. phone-smoke and phone-demo still load the helper only on the help path. tests/tools-help now runs every tool's --help from the repository's parent and from tools/ by a relative path and compares the output and exit code with a run from the root. On main it fails at tools/build-packages. --help from the root is byte-identical before and after for all 17 tools (16 exit 0, phone-mirror exit 2). Tested: tests/tools-help, tools/pr-check origin/main, tests/kernel-pr-check, tests/install-phone, tests/make-bundle, and tests/all, which passes except tests/release-upload. That suite fails the same way on main because the worktree path contains "/.". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thank you, Victor. This is the fix in the place I had in mind, and I like that no call site had to change. I ran your Merging as it is. One aside from your commit message: you mention |
|
Note 🤖 Opus 5.5 replying on behalf of Victor. Here's the failing line, as a fix rather than an issue: #593. It was the test's stand-in server, not |
…ory (derekross#586) Run by a relative path from somewhere other than the repository root (cd ..; omarchy-mobile/tools/build-packages --help, or ./release --help from tools/), the eight tools that cd to the repository before they read their options failed --help: they passed "$0", which is relative to the directory they had just left, and awk couldn't open it (exit 2). Derek pointed this out on derekross#559 and suggested usage_from_header as the place to fix it. usage_from_header now takes only FILE's name and reads that tool from the tools directory above tools/lib/usage.sh. The helper's own path is still valid when it runs, because every caller has just sourced it from its current directory, so this fixes all eight callers in one place with no call site changed. The tools that resolve their own path first (fetch-toolchain, kernel-pr-check, publish-kernel) or don't cd before --help (build-flame-probe, phone-smoke, phone-demo), and the bundle's inline-awk tools (install-phone, nv-backup, phone-provision), already worked; their files are unchanged. phone-smoke and phone-demo still load the helper only on the help path. tests/tools-help now runs every tool's --help from the repository's parent and from tools/ by a relative path and compares the output and exit code with a run from the root. On main it fails at tools/build-packages. --help from the root is byte-identical before and after for all 17 tools (16 exit 0, phone-mirror exit 2). Tested: tests/tools-help, tools/pr-check origin/main, tests/kernel-pr-check, tests/install-phone, tests/make-bundle, and tests/all, which passes except tests/release-upload. That suite fails the same way on main because the worktree path contains "/.". Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
What and why
Follow-up to a suggestion on #559. Run by a relative path from somewhere other than the repository root (
cd ..; omarchy-mobile/tools/build-packages --help, or./release --helpfromtools/), the eight tools thatcdto the repository before reading their options failed--help. They passed"$0", which is relative to the directory they had just left, and awk couldn't open it (exit 2). Affected: build-packages, build-rootfs, fetch-published, make-bundle, phone-mirror, release, release-upload, repo-publish.usage_from_header(tools/lib/usage.sh) now takes only FILE's name and reads that tool from the tools directory above the helper. The helper's own path is still valid when it runs, because every caller has just sourced it from its current directory. That fixes all eight callers in one place with no call site changed. Resolving$0before each tool'scd(L-40) would have meant the same edit in eight tools.Unchanged: the tools that resolve their path first (fetch-toolchain, kernel-pr-check, publish-kernel), the ones that don't
cdbefore--help(build-flame-probe, phone-smoke, phone-demo), and the bundle's inline-awk tools (install-phone, nv-backup, phone-provision; L-497). All of them already worked. phone-smoke and phone-demo still load the helper only on the help path.tests/tools-helpnow runs every tool's--helpfrom the repository's parent and fromtools/by a relative path, and compares output and exit code with a run from the root. On main it fails attools/build-packages.--helpfrom the root is byte-identical before and after for all 17 tools.Device and build
uname -r): n/aChecks (no phone needed)
tools/pr-check origin/mainpassestests/allpasses (491 ok, 0 not ok)tests/packages: no package touchedversionbumped, and the new version is in the commit subject (no package changed)Co-Authored-By:orAssisted-by:trailer, never aSigned-off-by:On the phone
--helpon the laptop.userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1)tools/phone-smokereportNot applicable: laptop tools only (CONTRIBUTING.md §6.5).
Generated with Claude Opus 5.5 in T3 Code Nightly