mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: deprecate os.exec (returning ?os.Result), in favour of os.execute, which returns os.Result (#8974)
This commit is contained in:
@@ -22,7 +22,10 @@ pub fn find_working_diff_command() ?string {
|
||||
}
|
||||
continue
|
||||
}
|
||||
p := os.exec('$diffcmd --version') or { continue }
|
||||
p := os.execute('$diffcmd --version')
|
||||
if p.exit_code < 0 {
|
||||
continue
|
||||
}
|
||||
if p.exit_code == 127 && diffcmd == env_difftool {
|
||||
// user setup is wonky, fix it
|
||||
return error('could not find specified VDIFF_TOOL $diffcmd')
|
||||
@@ -41,9 +44,12 @@ pub fn find_working_diff_command() ?string {
|
||||
|
||||
// determine if the FileMerge opendiff tool is available
|
||||
fn opendiff_exists() bool {
|
||||
o := os.exec('opendiff') or { return false }
|
||||
o := os.execute('opendiff')
|
||||
if o.exit_code < 0 {
|
||||
return false
|
||||
}
|
||||
if o.exit_code == 1 { // failed (expected), but found (i.e. not 127)
|
||||
if o.output.contains('too few arguments') { // got some exptected output
|
||||
if o.output.contains('too few arguments') { // got some expected output
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -53,7 +59,10 @@ fn opendiff_exists() bool {
|
||||
pub fn color_compare_files(diff_cmd string, file1 string, file2 string) string {
|
||||
if diff_cmd != '' {
|
||||
full_cmd := '$diff_cmd --minimal --text --unified=2 --show-function-line="fn " "$file1" "$file2" '
|
||||
x := os.exec(full_cmd) or { return 'comparison command: `$full_cmd` failed' }
|
||||
x := os.execute(full_cmd)
|
||||
if x.exit_code < 0 {
|
||||
return 'comparison command: `$full_cmd` not found'
|
||||
}
|
||||
return x.output.trim_right('\r\n')
|
||||
}
|
||||
return ''
|
||||
|
||||
@@ -229,7 +229,7 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) {
|
||||
if is_verbose {
|
||||
println('Compiling $tool_name with: "$compilation_command"')
|
||||
}
|
||||
tool_compilation := os.exec(compilation_command) or { panic(err) }
|
||||
tool_compilation := os.execute_or_panic(compilation_command)
|
||||
if tool_compilation.exit_code != 0 {
|
||||
eprintln('cannot compile `$tool_source`: \n$tool_compilation.output')
|
||||
exit(1)
|
||||
@@ -428,8 +428,9 @@ pub fn check_module_is_installed(modulename string, is_verbose bool) ?bool {
|
||||
if is_verbose {
|
||||
eprintln('check_module_is_installed: updating with $update_cmd ...')
|
||||
}
|
||||
update_res := os.exec(update_cmd) or {
|
||||
return error('can not start $update_cmd, error: $err')
|
||||
update_res := os.execute(update_cmd)
|
||||
if update_res.exit_code < 0 {
|
||||
return error('can not start $update_cmd, error: $update_res.output')
|
||||
}
|
||||
if update_res.exit_code != 0 {
|
||||
eprintln('Warning: `$modulename` exists, but is not updated.
|
||||
@@ -446,11 +447,12 @@ and the existing module `$modulename` may still work.')
|
||||
if is_verbose {
|
||||
eprintln('check_module_is_installed: cloning from $murl ...')
|
||||
}
|
||||
cloning_res := os.exec('git clone $murl $mpath') or {
|
||||
return error('git is not installed, error: $err')
|
||||
cloning_res := os.execute('git clone $murl $mpath')
|
||||
if cloning_res.exit_code < 0 {
|
||||
return error_with_code('git is not installed, error: $cloning_res.output', cloning_res.exit_code)
|
||||
}
|
||||
if cloning_res.exit_code != 0 {
|
||||
return error('cloning failed, details: $cloning_res.output')
|
||||
return error_with_code('cloning failed, details: $cloning_res.output', cloning_res.exit_code)
|
||||
}
|
||||
if !os.exists(mod_v_file) {
|
||||
return error('even after cloning, $mod_v_file is still missing')
|
||||
|
||||
Reference in New Issue
Block a user