Skip to content

Passing -p . explicitly is treated as "no path" and prompts, swallowing the next stdin line as the path #145

Description

@matt-edmondson

What's wrong

BaseVerb.PathString defaults to "." (Verbs/BaseVerb.cs:15). Each verb then checks if (PathString is "." or "") to decide whether to prompt for a path (Verbs/Deduplicate.cs:15, DryRun.cs:15, Scan.cs:15, Stats.cs:15). Because "." is both the default and the "not supplied" marker, an explicit -p . / --path . meaning "the current directory" can't be told apart from leaving the option out.

Failure scenario

These were run in a directory containing two identical files:

  • Scan -p . </dev/null prints Enter the path to scan: No path provided. Aborting. and does nothing. Scan -p ./ finds the duplicate group as expected.
  • echo y | Deduplicate -p . prints Enter the path to deduplicate: Deduplicating: <cwd>/y and then Directory not found: <cwd>/y. The y meant to confirm the deletion is read as the path. With different input piped in, the run could target a directory the user never meant.

Suggested fix

  • Make PathString a string? that defaults to null.
  • Prompt only when string.IsNullOrWhiteSpace(PathString).
  • Reset it to null rather than "." after a run.

Open PR #143 (for #138) moves the PathString = "." reset into a finally in BaseVerb<T>.Run. That PR is related but doesn't fix this, so the sentinel change should build on it.

Acceptance criteria

  • Scan -p . scans the current directory without prompting.
  • Leaving out -p still prompts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreadyFully specified; implement as written

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions