-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
This may be a known limitation, but I wanted to report it because it affects teaching CLI argument parsing on Windows.
On Windows, v run does not preserve quoted command-line arguments when forwarding them to the compiled program.
When a program prints os.args, arguments containing spaces (even when properly quoted in the shell) are split into multiple arguments. This occurs across different shells (PowerShell and Git Bash). The same program behaves correctly when compiled and executed directly, suggesting the issue is specific to how v run forwards arguments on Windows.
Using--does not resolve the issue; the separator itself is passed through into os.args.
This behaviour makes v run unreliable for testing or teaching CLI argument parsing on Windows, even though the language-level argument handling (os.args) works correctly.
Reproduction Steps
- Create a file named
try.vwith the following contents:
import os
fn main() {
println(os.args)
}-
Run the program using
v runon Windows:v run try.v add "Learn V" -
Actual output:
["try.exe", "add", "Learn", "V"]The quoted argument "Learn V" is split into two arguments.
-
Compile and run the executable directly:
v try.v
./try.exe add "Learn V" -
Expected output:
["try.exe", "add", "Learn V"] -
Using
--does not resolve the issue:v run try.v -- add "Learn V"The separator
--appears inos.argsand the quoted argument is still split.
Expected Behavior
When using v run on Windows, quoted command-line arguments should be forwarded to the executed program unchanged.
For example, running:
v run try.v add "Learn V"
should result in os.args containing a single argument "Learn V" rather than splitting it into "Learn" and "V", matching the behaviour observed when the compiled executable is run directly.
Current Behavior
On Windows, when running a program with v run, quoted command-line arguments containing spaces are split into multiple arguments in os.args.
For example, running:
v run try.v add "Learn V"
results in os.args containing separate entries for "Learn" and "V". Using -- does not prevent this and the separator itself appears in os.args.
The same program behaves correctly when compiled and executed directly.
Possible Solution
No concrete solution proposed.
It may be related to how v run forwards command-line arguments to the compiled program on Windows. Running the compiled executable directly works as expected, so documenting this limitation or adjusting argument forwarding in v run on Windows may resolve the issue.
Additional Information/Context
No response
V version
V 0.5.0 49bade5
Environment details (OS name and version, etc.)
|V full version |V 0.5.0 49bade567852d01003fa48c777259ec36dd7d2b6
|:-------------------|:-------------------
|OS |windows, Microsoft Windows 11 Pro 22000 64-bit
|Processor |8 cpus, 64bit, little endian, 11th Gen Intel(R) Core(TM) i7-1195G7 @ 2.90GHz
|Memory |19.43GB/31.7GB
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.