Skip to content

fix: drop malformed PATH entries before exporting them to terminals - #629

Merged
arzafran merged 3 commits into
mainfrom
franco/inc-1281-path-sanitize
Nov 15, 2026
Merged

arzafran merged 3 commits into
mainfrom
franco/inc-1281-path-sanitize

Conversation

@arzafran

Copy link
Copy Markdown
Member

What this does

If the PATH Programa inherits has an entry with broken bytes in it, new terminals and the tmux shim no longer pass that entry on. Before, Programa turned the broken bytes into replacement characters and exported them, so tools that check PATH strictly saw a corrupted value in every new pane.

Summary

Ported by behavior from cmux e36b8e8632 (manaflow-ai/cmux#12057).

  • Sources/TerminalPathEnvironment.swift is new and compiled into both the app and the CLI. It holds the two PATH builders that used to live inline in TerminalSurface (startup PATH with the bundled bin directory) and CLI+TmuxCompat (tmux shim PATH).
  • Entries containing U+FFFD or control characters are dropped. Empty entries stay, since they mean the current directory.
  • The startup PATH is now rewritten even when it already contains the bundled bin directory, but only if something was dropped. A clean PATH that already has it is still left alone, so its override behavior does not change.

Review order: the refactor commit (no behavior change), then the test commit, then the fix.

Test Plan

  • ./scripts/reload.sh --tag inc-1281 builds the app and CLI.
  • The new helper, compiled on its own with swiftc against the same cases as the tests: 7 of 7 match.
  • CI unit tests: four new cases in GhosttyTerminalStartupEnvironmentTests (programaTests/GhosttyConfigTests.swift) pass; three of them fail on the test-only commit.

Linear: INC-1281

The app's startup PATH and the CLI's tmux shim PATH now share one helper compiled into both targets. No behavior change.
An inherited PATH entry with invalid bytes decodes as U+FFFD and control characters, and Programa re-exports it to every new terminal and tmux shim. These tests fail until the PATH helper filters such entries.
An inherited PATH entry with invalid bytes decodes as U+FFFD, and Programa passed that text on to every new terminal and to the tmux shim PATH, so strict tools saw a corrupted PATH. The PATH helper now drops entries that carry U+FFFD or control characters, and the startup PATH is rewritten even when it already contains the bundled CLI directory.
@arzafran
arzafran merged commit 0ad8624 into main Nov 15, 2026
12 checks passed
@arzafran
arzafran deleted the franco/inc-1281-path-sanitize branch November 16, 2026 16:26
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.

1 participant