From 8a1324c1412c462f91d5a0e2571cbc597039bc31 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 17 Aug 2019 20:21:59 +0300 Subject: [PATCH] os: make exec() return ?Result with exit code and output --- compiler/cgen.v | 2 +- compiler/main.v | 12 +++++------ compiler/msvc.v | 10 +++++----- compiler/parser.v | 8 +++++--- vlib/os/os.v | 51 ++++++++++++++++++++++++++++------------------- 5 files changed, 48 insertions(+), 35 deletions(-) diff --git a/compiler/cgen.v b/compiler/cgen.v index 89659269da..238d8f613b 100644 --- a/compiler/cgen.v +++ b/compiler/cgen.v @@ -261,7 +261,7 @@ fn build_thirdparty_obj_file(flag string) { res := os.exec('$cc -fPIC -c -o $obj_path $cfiles') or { panic(err) } - println(res) + println(res.output) } fn os_name_to_ifdef(name string) string { diff --git a/compiler/main.v b/compiler/main.v index e29449e332..b841c2b053 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -924,7 +924,7 @@ mut args := '' '/usr/lib/x86_64-linux-gnu/crtn.o') or { panic(err) } - println(ress) + println(ress.output) println('linux cross compilation done. resulting binary: "$v.out_name"') } if !v.pref.is_debug && v.out_name_c != 'v.c' && v.out_name_c != 'v_macos.c' { @@ -1336,7 +1336,7 @@ fn run_repl() []string { s := os.exec('$vexe run $file -repl') or { panic(err) } - vals := s.split('\n') + vals := s.output.split('\n') for i:=0; i < vals.len; i++ { println(vals[i]) } @@ -1354,7 +1354,7 @@ fn run_repl() []string { panic(err) } lines << line - vals := s.split('\n') + vals := s.output.split('\n') for i:=0; i