Skip to content

Fix /cd failing on Windows when target directory contains '.'#324

Merged
mpfaffenberger merged 1 commit intompfaffenberger:mainfrom
wkramme:fix/windows-cd-dot-path-public
May 7, 2026
Merged

Fix /cd failing on Windows when target directory contains '.'#324
mpfaffenberger merged 1 commit intompfaffenberger:mainfrom
wkramme:fix/windows-cd-dot-path-public

Conversation

@wkramme
Copy link
Copy Markdown
Contributor

@wkramme wkramme commented May 7, 2026

Summary

Users reported that /cd can fail on Windows when the target directory contains a dot (for example: repo.v2).

This PR fixes that behavior.

User-facing issue

On Windows, commands like the following could fail with Not a directory even when the directory exists:

  • /cd C:\Users\alice\repo.v2
  • /cd "C:\Users\alice\repo.v2"

Root cause

handle_cd_command() used POSIX-style shlex.split() for all platforms.
On Windows, that parsing can corrupt native backslash paths, causing directory checks to fail.
Dotted folder names were a common real-world case where this surfaced.

What changed

code_puppy/command_line/core_commands.py

  • Use non-POSIX shlex parsing on Windows (os.name == "nt") to preserve Windows path semantics.
  • Keep existing POSIX parsing behavior on non-Windows platforms.
  • Improve fallback parsing with split(maxsplit=1).
  • Normalize surrounding quotes on the parsed directory argument.

tests/command_line/test_core_commands_extended.py

Added regression tests for Windows /cd with dotted directory names:

  1. Unquoted path (C:\...\repo.v2)
  2. Quoted path ("C:\...\repo.v2")

Validation

  • uv run pytest -q tests/command_line/test_core_commands_extended.py -k "cd_windows or cd_with_special_characters or cd_with_relative_path or cd_with_tilde_expansion"
  • uv run pytest -q tests/test_command_handler.py -k "test_cd_"

Risk

Low. Change is scoped to /cd parsing with focused regression coverage.

@wkramme wkramme marked this pull request as ready for review May 7, 2026 15:36
@mpfaffenberger mpfaffenberger merged commit a789685 into mpfaffenberger:main May 7, 2026
2 checks passed
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.

2 participants