fix vtool used with paths w/spaces (win/nix)

pull/2795/head
joe-conigliaro 2019-11-17 22:36:05 +11:00 committed by Alexander Medvednikov
parent 43863edc4f
commit 6d7fe1f83c
2 changed files with 6 additions and 5 deletions

View File

@ -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) )
}

View File

@ -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)
}