Repository navigation
fix(cd): search CDPATH for empty OLDPWD to match POSIX and Bash 5.3 - #790
privatenumber wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Additional findings
-
packages/just-bash/src/interpreter/builtins/cd.ts:57-62— With an empty OLDPWD andCDPATH=:/tmp, the newly enabled lookup skips the current-directory entry and incorrectly makescd -change to/tmp. -
packages/just-bash/src/interpreter/builtins/cd.ts:57-62— Removing the empty-target guard also makesCDPATH=/tmp; cd ""change directory to/tmp, although Bash 5.3 rejects an explicit empty operand without changing directory.
🤖 auto-maintain reviewAutomated, advisory triage for
Review panel: 🟡 medium highest severity just-bash maintainer code review: 🟢 low
General code review: 🟡 medium
Adversarial security: 🟡 medium
Adversarial security (second opinion): 🟢 low
Standard Bash and host portability: 🟢 low
Posted by auto-maintain. This automated code review is advisory; a human maintainer makes the call. |
Problem
comparison-testshas been failing onmainand all PRs sinceubuntu-latestrolled fromubuntu-24.04(Bash 5.2) toubuntu-26.04(Bash 5.3) between Nov 16 and Nov 20:In Bash 5.3 (
builtins/cd.def),cd -searchesCDPATHwhen$OLDPWDis not an absolute pathname (matching POSIXcdstep 5 anddash), whereas Bash <= 5.2 skippedCDPATHoncd -.cd.tshad atarget !== ""guard added in#439for Bash <= 5.2.Changes
packages/just-bash/src/interpreter/builtins/cd.ts: remove thetarget !== ""guard from theCDPATHlookup socd -with an emptyOLDPWDsearchesCDPATH(while keepingcwdunchanged and printing an empty line whenCDPATHis unset or does not match).packages/just-bash/src/interpreter/builtins/cd.test.ts: cover bothCDPATH=/tmp(/tmp\n/tmp\n) andunset CDPATH(\n/home/user\n) with emptyOLDPWD.packages/just-bash/src/comparison-tests/fixtures/cd.comparison.fixtures.json: re-record the fixture on Bash 5.3.Verification
RECORD_FIXTURES=1 pnpm --filter just-bash test:comparison src/comparison-tests/cd.comparison.test.ts(10 passed)pnpm --filter just-bash test:comparison src/comparison-tests/cd.comparison.test.ts(10 passed)pnpm --filter just-bash test:run src/interpreter/builtins/cd.test.ts(13 passed)pnpm typecheck(passed)pnpm lint(passed)