Skip to content

Strip the quotes from a path pasted at the prompt [patch] - #199

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/152-quoted-path-prompt
Nov 4, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/152-quoted-path-prompt

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #152

What was wrong

Explorer's Copy as path, and dragging a folder with a space into a terminal, both wrap the path in quotes. The path prompt only called .Trim(), so the quotes stayed in the string, and Path.GetFullPath resolved the quoted text as a relative name under the current directory. The result was Scanning: /cwd/"/some dir" followed by Directory not found.

Change

  • The four copies of the prompt in Scan, DryRun, Deduplicate and Stats move into one helper, BaseVerb.PromptForPathIfMissing(action). Each verb's ValidateArgs now calls it.
  • The helper removes one matching pair of surrounding " or ' (BaseVerb.Unquote) before it uses the answer. A quoted empty answer ("") aborts the same way an empty one does.
  • A mismatched pair, a lone quote, and an unquoted path are left as they are.

Tests

QuotedPathPromptTests drives the prompt through stdin using the existing ConsoleCapture helper:

  • Scan with "dir", 'dir' and a padded "dir" scans the directory and finds the duplicate group.
  • Stats, DryRun and Deduplicate each accept a quoted path.
  • Unquote cases cover "C:\some dir", '/some dir', a mismatched pair, a lone ", and doubled quotes.
  • "" aborts with exit code 1.

With the Unquote call reverted, 5 of these tests fail. With it in place the full suite passes: 133 total, 130 passed, 3 skipped. The 3 skips are permission tests that are inconclusive when run as root.


Generated by Claude Code

Explorer's Copy as path, and dragging a folder with a space into a
terminal, wrap the path in quotes. The prompt only trimmed its input, so
the quotes stayed in and Path.GetFullPath resolved the quoted text under
the current directory, reporting "Directory not found".

The four copies of the prompt in Scan, DryRun, Deduplicate and Stats
move into BaseVerb.PromptForPathIfMissing, which removes one matching
pair of surrounding " or ' before using the answer.

Fixes #152

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW2CxWzSsPmDZkw2R6J
@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit ea22867 into main Nov 4, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/152-quoted-path-prompt branch November 4, 2026 01:02
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.

A quoted path pasted at the "Enter the path" prompt is scanned as <cwd>/"<path>" and reported as "Directory not found"

2 participants