Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
weskoerber opened this issue Jan 10, 2025 · 0 comments

Comments

@weskoerber
Copy link

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

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

No branches or pull requests

1 participant