fix: cd resolves .. against $PWD without re-stat'ing the cwd#195
Open
avaer wants to merge 1 commit into
Open
Conversation
|
@avaer is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
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.
The cd builtin walked every component of the target path — including those of ctx.state.cwd — calling fs.stat on each. If the current working directory had been removed (e.g.
rm -rf $PWD),cd ..would fail with "No such file or directory" because stat'ing the deleted cwd aborted the walk before..could pop it.Real bash uses logical (-L) semantics: $PWD anchors resolution and is not re-stat'd, so
cd ..from a deleted cwd resolves textually to the parent. Intermediate components from the user-supplied target still get stat'd, socd nonexistent/..continues to error like bash.Seed the resolution stack from ctx.state.cwd for relative targets, pop on
.., and stat only components newly pushed by the target. Adds unit tests for deleted-cwd escape plus intermediate-missing errors, and comparison tests asserting parity with real bash.