Skip to content

Resolve a relative executable path against WorkingDirectory [patch] - #131

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/115-resolve-relative-executable-against-working-directory
Nov 4, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/115-resolve-relative-executable-against-working-directory

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #115

Summary

Process.Start resolves a relative FileName against the calling process's current directory, not against ProcessStartInfo.WorkingDirectory. So ExecuteAsync("./build.sh", …, new() { WorkingDirectory = repo }) ran whichever build.sh was in the caller's current directory. If there was none, it failed with an error that named the directory that did contain the script.

CreateStartInfo now passes the file name through a new ResolveFileName before starting the process. When a WorkingDirectory is set and the file name is relative with a directory part, it is resolved against WorkingDirectory. Examples are ./x and sub/x, plus .\x on Windows. This matches cd repo && ./build.sh in a shell.

  • Bare names (git, dotnet) keep the usual search.
  • Absolute paths are unchanged.
  • Without a WorkingDirectory, nothing changes.

The README's Working Directory section now states these rules.

Tests

  • New ExecuteAsyncShouldResolveARelativeExecutablePathAgainstTheWorkingDirectory, with ./script and sub/script cases. It puts a same-named script in both the working directory and the caller's current directory, then asserts that the working directory's copy ran. It writes .cmd scripts on Windows and .sh elsewhere.
  • Without the fix, both cases fail because the caller's copy runs. With it, both pass.
  • dotnet build RunCommand.sln is clean for every target framework. Full suite: 66 passed, 0 failed, 2 skipped (the Windows-only tests).

Generated by Claude Code

Process.Start resolves a relative FileName against the caller's current
directory, so ./build.sh with WorkingDirectory set ran the caller's copy or
failed to start. Combine a relative path that has a directory part with the
working directory; bare names keep the usual search and absolute paths are
unchanged.

Fixes #115

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

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 1ab184b into main Nov 4, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/115-resolve-relative-executable-against-working-directory branch November 4, 2026 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants