From c66ee8aa61254f0051be995bc1f04152a84a1ced Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 5 Jan 2021 10:00:15 +0800 Subject: [PATCH] tools/vself: minor optimization (#7877) --- cmd/tools/vself.v | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cmd/tools/vself.v b/cmd/tools/vself.v index 7f73256ae5..696ec356b0 100644 --- a/cmd/tools/vself.v +++ b/cmd/tools/vself.v @@ -23,13 +23,12 @@ fn main() { // The user just wants an independent copy of v, and so we are done. return } - backup_old_version_and_rename_newer() + backup_old_version_and_rename_newer() or { panic(err) } + println('V built successfully!') } fn compile(vroot string, cmd string) { - result := os.exec(cmd) or { - panic(err) - } + result := os.exec(cmd) or { panic(err) } if result.exit_code != 0 { eprintln('cannot compile to `$vroot`: \n$result.output') exit(1) @@ -39,13 +38,13 @@ fn compile(vroot string, cmd string) { } } -fn backup_old_version_and_rename_newer() { +fn backup_old_version_and_rename_newer() ? { v_file := if os.user_os() == 'windows' { 'v.exe' } else { 'v' } v2_file := if os.user_os() == 'windows' { 'v2.exe' } else { 'v2' } bak_file := if os.user_os() == 'windows' { 'v_old.exe' } else { 'v_old' } if os.exists(bak_file) { - os.rm(bak_file) + os.rm(bak_file) ? } - os.mv(v_file, bak_file) - os.mv(v2_file, v_file) + os.mv(v_file, bak_file) ? + os.mv(v2_file, v_file) ? }