diff --git a/vlib/compiler/vtools.v b/vlib/compiler/vtools.v index 61f561bb6a..72429acbfe 100644 --- a/vlib/compiler/vtools.v +++ b/vlib/compiler/vtools.v @@ -6,12 +6,12 @@ pub fn launch_tool(tname string){ vexe := vexe_path() vroot := os.dir(vexe) mut oargs := os.args - oargs[0] = vexe // make it more explicit + oargs[0] = '"$vexe"' // make it more explicit tool_exe := os.realpath('$vroot/tools/$tname') tool_source := os.realpath('$vroot/tools/${tname}.v') ////////////////////////////////////////////////////// tool_args := oargs.join(' ') - tool_command := '$tool_exe $tool_args' + tool_command := '"$tool_exe" $tool_args' //println('Launching: "$tool_command" ...') mut tool_should_be_recompiled := false @@ -31,13 +31,12 @@ pub fn launch_tool(tname string){ } if tool_should_be_recompiled { - compilation_command := '$vexe $tool_source' + compilation_command := '"$vexe" "$tool_source"' //println('Compiling $tname with: "$compilation_command"') tool_compilation := os.exec(compilation_command) or { panic(err) } if tool_compilation.exit_code != 0 { panic('V tool "$tool_source" could not be compiled\n' + tool_compilation.output) } } - exit( os.system(tool_command) ) } diff --git a/vlib/os/os.v b/vlib/os/os.v index 46880e61f4..e87eee6033 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -399,7 +399,9 @@ pub fn system(cmd string) int { } mut ret := int(0) $if windows { - ret = C._wsystem(cmd.to_wide()) + // overcome bug in system & _wsystem (cmd) when first char is quote `"` + wcmd := if cmd.len > 1 && cmd[0] == `"` && cmd[1] != `"` { '"$cmd"' } else { cmd } + ret = C._wsystem(wcmd.to_wide()) } $else { ret = C.system(cmd.str) }