Quoting problems on Windows
- Dominant language
- Rust
- Stars
- 35.8k
- Forks
- 846
- Avg merge
- 27m
- Merged PRs (30d)
- 3
Description
I have the following script (reduced for brevity):
```just
set windows-shell := ["cmd.exe", "/c"]
clang := if `where clang 2>NUL || exit 0` == "" {
error("cannot find clang compiler")
} else {
trim(replace(`where clang`, "\\", "\\\\"))
}
test:
{{clang}} --version
```
Running `just test` fails with the error message: `'C:\\Program' is not recognized as an internal or external command, operable program or batch file.`. This is expected as that is how cmd normally operates.
Changing `{{clang}}` to `{{quote(clang)}}` fails with the error message: `The filename, directory name, or volume label syntax is incorrect.`. This is because `quote()` uses single quotes which has a specific use case on Windows, rather than double quotes which works universally.
Changing `{{clang}}` to `"{{clang}}"` fails with the error message: `'\"C:\\Program Files\\LLVM\\bin\\clang.exe\"' is not recognized as an internal or external command, operable program or batch file.`. I'm not entirely sure what's going on here, but the most I could conclude is that the quotations from the command are being escaped for some reason.
With these issues in mind, what is the right way to go about running executables with spaces in the file path?
Contributor guide
Assessment
This issue has not been assessed yet.