Skip to content

fix: make all 18 bin/ scripts CDPATH-safe - #837

Closed
Ziadstr wants to merge 1 commit into
garrytan:mainfrom
Ziadstr:fix/cdpath-safe-all-bin
Closed

Ziadstr wants to merge 1 commit into
garrytan:mainfrom
Ziadstr:fix/cdpath-safe-all-bin

Conversation

@Ziadstr

@Ziadstr Ziadstr commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Root cause

When CDPATH is set (common with zsh users, zoxide, or custom navigation), cd prints the resolved path to stdout. This doubles the output of $(cd ... && pwd), corrupting GSTACK_DIR, SCRIPT_DIR, and REPO_ROOT assignments. Most visibly, gstack-update-check silently exits because VERSION_FILE becomes a two-line string.

Fix

# Before (broken with CDPATH):
GSTACK_DIR="$(cd "$(dirname "$0")/.." && pwd)"

# After (works with any CDPATH):
GSTACK_DIR="$(cd "$(dirname "$0")/.." >/dev/null && pwd)"

All 18 scripts fixed

dev-setup, dev-teardown, gstack-community-dashboard, gstack-extension, gstack-learnings-log, gstack-learnings-search, gstack-platform-detect, gstack-relink, gstack-repo-mode, gstack-review-log, gstack-review-read, gstack-specialist-stats, gstack-telemetry-log, gstack-telemetry-sync, gstack-timeline-log, gstack-timeline-read, gstack-uninstall, gstack-update-check.

Testing

bash -n bin/dev-setup bin/dev-teardown bin/gstack-community-dashboard \
  bin/gstack-extension bin/gstack-learnings-log bin/gstack-learnings-search \
  bin/gstack-platform-detect bin/gstack-relink bin/gstack-repo-mode \
  bin/gstack-review-log bin/gstack-review-read bin/gstack-specialist-stats \
  bin/gstack-telemetry-log bin/gstack-telemetry-sync bin/gstack-timeline-log \
  bin/gstack-timeline-read bin/gstack-uninstall bin/gstack-update-check

All 18 pass syntax check. Fix verified with CDPATH='.:/tmp' set.

Note: PR #836 fixes 7 of 18 scripts. This PR covers all 18.

Fixes #824

…uption

When CDPATH is set, cd prints the resolved path to stdout, corrupting
$(cd ... && pwd) assignments. This breaks all bin/ scripts by doubling
the directory path in variable assignments.

Fix: redirect cd stdout to /dev/null in all path resolution patterns.
pwd still outputs the correct path to stdout for the command substitution.

Fixes garrytan#824
@garrytan

Copy link
Copy Markdown
Owner

Closing — duplicate of several PRs fixing the same CDPATH issue in bin/ scripts. Thank you for the contribution!

@garrytan garrytan closed this Apr 16, 2026
capy-ai Bot added a commit that referenced this pull request Nov 17, 2026
… result (GST-2349) (#4285)

* Stop /ship's docs audit halting when the child writes prose after its result (GST-2349)

The Step 14.5 documentation audit read only the child's last nonempty line.
Children that ended with their JSON result and then restated the documentation
section in prose had a valid "current, no edits" audit rejected with no format
repair, which spent an attempt each time and, after two, stopped /ship for an
owner risk grant (founderstar #837, harness-evals #393).

gstack-docs-candidate result now reads the last line that opens a JSON object,
ignores prose after it and says so with TRAILING_PROSE:. A result missing only
documentation_section keeps the existing free re-ask, whose prompt now tells the
child to put the section inside the JSON and write nothing after the line; the
re-audit retry note says the same. Content failures still count.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Send any docs-audit result with text after it back for one free re-ask (GST-2349)

A cross-family audit of the previous commit showed that ignoring prose after
the result line let a contradicting verdict through: a blocked result followed
by a fenced "current" example was accepted as current, and a "Correction: the
audit is BLOCKED" after a current line became a repair that had to stay current.

Text after a JSON line carrying the audit id is no longer ignored and never
searched for another result. It is a format slip: FORMAT_REPAIR re-asks once
for the whole result line without spending an attempt, the re-ask counts
everything the audit wrote after its JSON line, and the reply is judged on its
own with nothing kept from the first line. A reply that itself has text after
its line counts as an attempt.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Keep a blocked docs audit blocked through the free re-ask (GST-2349)

Review of the previous change found that the free whole-line re-ask could
turn a blocked audit into a passing one: a blocked result line, then a fenced
"current" example, then a "current" reply was accepted as current.

The re-ask now works one way. It is offered only when every JSON line that
carries the audit id is free of content problems; a content problem such as a
missing status or "current" with edits still spends an attempt. If any of those
lines said blocked or listed a blocker, the reply must stay blocked and keep
every blocker (it may add more), and the re-ask prompt says so.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CDPATH breaks all bin/ scripts — cd outputs path to stdout, corrupting variable assignments

2 participants