casey / casey/just

Quoting problems on Windows

Open
#1,639 2 comments 1 reaction 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.