Skip to content

Running with --shell=none fails with Windows paths containing backslashes (\), works with forward slashes (/) #796

@weskoerber

Description

@weskoerber

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

  1. Be on Windows
  2. Use a command with Windows-style path (e.g. C:\path\to\program.exe or path\to\program.exe)
  3. Run the command with hyperfine with --shell=none (e.g. hyperfine --shell=none C:\path\to\program.exe)
  4. Observe the program not found error.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requestedwindows

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions