Fix CDPATH breaking all bin/ scripts + fragile JSON stripping via sed#853
Open
urbantech wants to merge 1 commit intogarrytan:mainfrom
Open
Fix CDPATH breaking all bin/ scripts + fragile JSON stripping via sed#853urbantech wants to merge 1 commit intogarrytan:mainfrom
urbantech wants to merge 1 commit intogarrytan:mainfrom
Conversation
CDPATH (garrytan#824): All 23 shell scripts use SCRIPT_DIR="$(cd ... && pwd)" to find their location. When CDPATH is set, cd prints the target directory to stdout, corrupting the captured path. Fix: prefix with CDPATH= to unset it for the subshell. Affected: 22 files in bin/, scripts/, browse/scripts/, setup, supabase/ Telemetry JSON (garrytan#710): gstack-telemetry-sync stripped JSON fields via sed patterns that break on escaped quotes and edge-positioned fields. Replace with bun -e JSON.parse/delete/stringify for correct handling. Falls back to original line on parse failure. Fixes garrytan#824, fixes garrytan#710
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
#824 — CDPATH breaks all bin/ scripts
Every shell script uses
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"to find its location. WhenCDPATHis set (common in power-user dotfiles),cdprints the target directory to stdout, prepending garbage to the captured path.Fix:
CDPATH= cd— unsets CDPATH for the subshell. Standard POSIX fix.23 files across
bin/,scripts/,browse/scripts/,setup,supabase/.#710 — Fragile JSON manipulation via sed in telemetry sync
gstack-telemetry-syncstripped JSON fields using sed patterns likes/,"_repo_slug":"[^"]*"//g. This breaks on:\")Fix: Replace with
bun -eJSON.parse/delete/stringify. Falls back to the original line on parse failure. Bun is guaranteed available.Test Plan
CDPATH="/usr:/var" SCRIPT_DIR="$(CDPATH= cd ... && pwd)"returns correct path_repo_slug,_branch,repofields correctly strippedFixes #824, fixes #710