fix: CDPATH breaks all bin/ scripts — cd stdout corrupts path variables#918
Open
Hybirdss wants to merge 1 commit intogarrytan:mainfrom
Open
fix: CDPATH breaks all bin/ scripts — cd stdout corrupts path variables#918Hybirdss wants to merge 1 commit intogarrytan:mainfrom
Hybirdss wants to merge 1 commit intogarrytan:mainfrom
Conversation
…upting variables When CDPATH is set (common with zsh users, zoxide, custom navigation), `cd` prints the resolved path to stdout if it resolves through CDPATH. This doubles the output of `$(cd ... && pwd)`, corrupting GSTACK_DIR, SCRIPT_DIR, and every path derived from them. Most visible impact: gstack-update-check silently exits because VERSION_FILE becomes a two-line string, `[ -f "$VERSION_FILE" ]` fails, and upgrade detection never runs. Fix: redirect cd stdout with `>/dev/null 2>&1` in all 18 bin/ scripts (21 call sites). This is the standard POSIX-safe pattern for cd inside command substitution. Closes garrytan#824
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
CDPATHis set (common with zsh users, zoxide, custom.zshrcnavigation),cdprints the resolved path to stdout if it resolves throughCDPATH. This doubles the output of$(cd ... && pwd), corruptingGSTACK_DIR,SCRIPT_DIR, and every path derived from them.Most visible impact:
gstack-update-checksilently exits —VERSION_FILEbecomes a two-line string,[ -f "$VERSION_FILE" ]fails, and upgrade detection never runs. Users withCDPATHset are permanently stuck on their installed version.Fix: redirect
cdstdout with>/dev/null 2>&1in all path-resolution patterns. This is the standard POSIX-safe idiom forcdinside command substitution.18 files, 21 call sites:
Before (broken):
After (fixed):
Reproduction
Scope
This PR fixes
bin/scripts only. The same pattern exists insetup,scripts/build-app.sh,scripts/app/gstack-browser,browse/scripts/build-node-server.sh,gstack-upgrade/migrations/v0.15.2.0.sh, andsupabase/verify-rls.sh— flagging as a follow-up to keep this PR focused.Test plan
CDPATH=".:/tmp" bash bin/gstack-update-check --force— no longer silently exits$(cd path >/dev/null 2>&1 && pwd)returns single line withCDPATHsetCDPATHset (confirmed the bug)bun testpasses (6 pre-existing failures, 0 new — golden file + version mismatch)Closes #824
Generated with Claude Code