fix(shell): quote shellrc source guard so ZDOTDIR with spaces works#2860
Open
mikeland73 wants to merge 1 commit into
Open
fix(shell): quote shellrc source guard so ZDOTDIR with spaces works#2860mikeland73 wants to merge 1 commit into
mikeland73 wants to merge 1 commit into
Conversation
The `[ -f <path> ]` guard around sourcing the user's shellrc was unquoted. When ZDOTDIR (and thus the path) contains a space — e.g. a terminal integration setting ".../Application Support/..." — the path split into multiple words, `[` failed with "too many arguments", and the user's real shellrc never got sourced. Quote the path in both the zsh and bash branches. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes devbox-generated shellrc guards so that sourcing a user’s original shell rc file works even when the rc path contains spaces (notably when ZDOTDIR points into paths like .../Application Support/...). It updates the shellrc template accordingly, refreshes golden test fixtures, and adds a regression test to prevent reintroducing the issue.
Changes:
- Quote
.OriginalInitPathin the[ -f ... ]guard ininternal/devbox/shellrc.tmplfor both the zsh and non-zsh branches. - Update shellrc golden files to match the newly quoted guard output.
- Add a regression test to ensure a space-containing
ZDOTDIRproduces a quoted guard and that the guard line no longer fails withtoo many arguments.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/devbox/shellrc.tmpl | Quotes the -f guard path to prevent word-splitting when rc paths contain spaces. |
| internal/devbox/shell_test.go | Adds regression coverage for ZDOTDIR paths containing spaces and validates guard execution via /bin/sh. |
| internal/devbox/testdata/shellrc/basic/shellrc.golden | Updates expected generated shellrc output with the quoted guard. |
| internal/devbox/testdata/shellrc/zsh_zdotdir/shellrc.golden | Updates expected generated zsh shellrc output with the quoted guard. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
The
[ -f <path> ]guard that devbox generates around sourcing the user's original shellrc was unquoted in both the zsh and bash branches ofshellrc.tmpl. WhenZDOTDIR(and therefore the baked-in path) contains a space — e.g. a terminal integration that sets.../Application Support/...— the path split into multiple words,[failed withtoo many arguments, the wholeifblock was skipped, and the user's real shellrc (prompt, aliases, oh-my-zsh, etc.) never got sourced. This quotes the path in both branches and updates the affected golden files.How was it tested?
devbox run -- go test ./internal/devbox/passes, including a new regression testTestWriteDevboxShellrcZDOTDIRWithSpacesthat builds a shellrc from aZDOTDIRcontainingApplication Support, asserts the guard is quoted, and runs the generated guard line through/bin/shto confirm it no longer errors with "too many arguments".Community Contribution License
All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.
By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.
🤖 Generated with Claude Code