Running with --shell=none fails with Windows paths containing backslashes (\), works with forward slashes (/)
When running with --shell=none, Windows file paths that contain backslashes (\) throw a program not found error. However, when I use forward slashes (/) instead of backslashes the command works as expected. This is the case for both relative and absolute paths.
Steps to reproduce
- Be on Windows
- Use a command with Windows-style path (e.g.
C:\path\to\program.exeorpath\to\program.exe) - Run the command with hyperfine with
--shell=none(e.g.hyperfine --shell=none C:\path\to\program.exe) - Observe the
program not founderror.
Actual Behavior
The command fails with a program not found error when using backslashes (\) in the path.
Expected behavior
The command should work with Windows paths using backslashes (\) without errors.
Additional Information
Changing the path to use forward slashes (/) instead of backslashes (\) resolves the issue. Also, using default shell works as expected.
Examples
Program not found with --shell=none and backslashes
PS C:\Users\wes> hyperfine -N 'Downloads\inez-bench.exe'
Benchmark 1: Downloads\inez-bench.exe
Error: Failed to run command 'Downloads\inez-bench.exe': program not found
Working with --shell=none and forward slashes
PS C:\Users\wes> hyperfine -N 'Downloads/inez-bench.exe'
Benchmark 1: Downloads/inez-bench.exe
Time (mean ± σ): 2.6 ms ± 0.1 ms [User: 0.0 ms, System: 0.0 ms]
Range (min … max): 2.4 ms … 3.1 ms 1197 runs
Working with backslashes using default shell
PS C:\Users\wes> hyperfine 'Downloads\inez-bench.exe'
Benchmark 1: Downloads\inez-bench.exe
Time (mean ± σ): 4.0 ms ± 0.3 ms [User: 0.1 ms, System: 0.4 ms]
Range (min … max): 3.5 ms … 6.2 ms 377 runs
Environment
Hyperfine version: 0.19.0 (winget)
Windows version: 23H2 (Build 22631.4602)
Powershell version: 7.4.6
Thank you for reporting this. I assume you might need to use \\, because otherwise, something like the \p in some\program would be interpreted as an escape sequence.