diff --git a/cmd/tools/check_os_api_parity.v b/cmd/tools/check_os_api_parity.v index d4b925c66f..de6242ba37 100644 --- a/cmd/tools/check_os_api_parity.v +++ b/cmd/tools/check_os_api_parity.v @@ -42,7 +42,7 @@ fn main() { vexe := pref.vexe_path() vroot := os.dir(vexe) util.set_vroot_folder(vroot) - os.chdir(vroot) + os.chdir(vroot) ? cmd := diff.find_working_diff_command() or { '' } mut app := App{ diff_cmd: cmd diff --git a/cmd/tools/gen_vc.v b/cmd/tools/gen_vc.v index c2e8746b3e..86057aa69f 100644 --- a/cmd/tools/gen_vc.v +++ b/cmd/tools/gen_vc.v @@ -215,7 +215,7 @@ fn (mut gen_vc GenVC) generate() { } } // cd to gen_vc dir - os.chdir(gen_vc.options.work_dir) + os.chdir(gen_vc.options.work_dir) or {} // if we are not running with the --serve flag (webhook server) // rather than deleting and re-downloading the repo each time // first check to see if the local v repo is behind master diff --git a/cmd/tools/modules/scripting/scripting.v b/cmd/tools/modules/scripting/scripting.v index edf6a0ade3..342b9b7778 100644 --- a/cmd/tools/modules/scripting/scripting.v +++ b/cmd/tools/modules/scripting/scripting.v @@ -85,7 +85,10 @@ fn modfn(mname string, fname string) string { pub fn chdir(path string) { verbose_trace_strong(modfn(@MOD, @FN), 'cd $path') - os.chdir(path) + os.chdir(path) or { + verbose_trace(modfn(@MOD, @FN), '## failed.') + return + } } pub fn mkdir(path string) ? { diff --git a/cmd/tools/vbug.v b/cmd/tools/vbug.v index 5e3fa1b2ce..67fc186a2e 100644 --- a/cmd/tools/vbug.v +++ b/cmd/tools/vbug.v @@ -22,12 +22,12 @@ fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string { mut vexe := os.getenv('VEXE') // prepare a V compiler with -g to have better backtraces if possible wd := os.getwd() - os.chdir(vroot) + os.chdir(vroot) or {} verbose_flag := if is_verbose { '-v' } else { '' } vdbg_path := $if windows { '$vroot/vdbg.exe' } $else { '$vroot/vdbg' } vdbg_compilation_cmd := '"$vexe" $verbose_flag -g -o "$vdbg_path" cmd/v' vdbg_result := os.execute(vdbg_compilation_cmd) - os.chdir(wd) + os.chdir(wd) or {} if vdbg_result.exit_code == 0 { vexe = vdbg_path } else { diff --git a/cmd/tools/vbuild-tools.v b/cmd/tools/vbuild-tools.v index 19905ab16e..7ad1dbb0d2 100644 --- a/cmd/tools/vbuild-tools.v +++ b/cmd/tools/vbuild-tools.v @@ -23,7 +23,7 @@ fn main() { args_string := os.args[1..].join(' ') vexe := os.getenv('VEXE') vroot := os.dir(vexe) - os.chdir(vroot) + os.chdir(vroot) ? folder := os.join_path('cmd', 'tools') tfolder := os.join_path(vroot, 'cmd', 'tools') main_label := 'Building $folder ...' diff --git a/cmd/tools/vcreate_test.v b/cmd/tools/vcreate_test.v index fe829e6238..fd09616f51 100644 --- a/cmd/tools/vcreate_test.v +++ b/cmd/tools/vcreate_test.v @@ -45,7 +45,7 @@ fn test_v_init() ? { defer { os.rmdir_all(dir) or {} } - os.chdir(dir) + os.chdir(dir) ? init_and_check() ? } @@ -57,7 +57,7 @@ fn test_v_init_in_git_dir() ? { defer { os.rmdir_all(dir) or {} } - os.chdir(dir) + os.chdir(dir) ? os.execute_or_exit('git init .') init_and_check() ? } @@ -70,7 +70,7 @@ fn test_v_init_no_overwrite_gitignore() ? { defer { os.rmdir_all(dir) or {} } - os.chdir(dir) + os.chdir(dir) ? vexe := @VEXE os.execute_or_exit('$vexe init') diff --git a/cmd/tools/vpm.v b/cmd/tools/vpm.v index 2031e156c0..a1c8eafcc1 100644 --- a/cmd/tools/vpm.v +++ b/cmd/tools/vpm.v @@ -333,7 +333,7 @@ fn vpm_update(m []string) { mut errors := 0 for name in module_names { final_module_path := valid_final_path_of_existing_module(name) or { continue } - os.chdir(final_module_path) + os.chdir(final_module_path) or {} println('Updating module "$name"...') verbose_println(' work folder: $final_module_path') vcs := vcs_used_in_dir(final_module_path) or { continue } @@ -361,7 +361,7 @@ fn get_outdated() ?[]string { mut outdated := []string{} for name in module_names { final_module_path := valid_final_path_of_existing_module(name) or { continue } - os.chdir(final_module_path) + os.chdir(final_module_path) or {} vcs := vcs_used_in_dir(final_module_path) or { continue } vcs_cmd_steps := supported_vcs_outdated_steps[vcs[0]] mut outputs := []string{} diff --git a/cmd/tools/vself.v b/cmd/tools/vself.v index 951b1cd7cf..5c8d1d2a60 100644 --- a/cmd/tools/vself.v +++ b/cmd/tools/vself.v @@ -11,7 +11,7 @@ fn main() { vexe := pref.vexe_path() vroot := os.dir(vexe) recompilation.must_be_enabled(vroot, 'Please install V from source, to use `v self` .') - os.chdir(vroot) + os.chdir(vroot) ? os.setenv('VCOLORS', 'always', true) args := os.args[1..].filter(it != 'self') jargs := args.join(' ') diff --git a/cmd/tools/vtest-all.v b/cmd/tools/vtest-all.v index 1a8bf0a8be..6c32d73578 100644 --- a/cmd/tools/vtest-all.v +++ b/cmd/tools/vtest-all.v @@ -156,7 +156,7 @@ fn get_all_commands() []Command { fn (mut cmd Command) run() { // Changing the current directory is needed for some of the compiler tests, // vlib/v/tests/local_test.v and vlib/v/tests/repl/repl_test.v - os.chdir(vroot) + os.chdir(vroot) or {} if cmd.label != '' { println(term.header_left(cmd.label, '*')) } diff --git a/cmd/tools/vtest-cleancode.v b/cmd/tools/vtest-cleancode.v index d7e9287b1d..82c078434a 100644 --- a/cmd/tools/vtest-cleancode.v +++ b/cmd/tools/vtest-cleancode.v @@ -64,7 +64,7 @@ fn main() { } fn tsession(vargs string, tool_source string, tool_cmd string, tool_args string, flist []string, slist []string) testing.TestSession { - os.chdir(vroot) + os.chdir(vroot) or {} title_message := 'running $tool_cmd over most .v files' testing.eheader(title_message) mut test_session := testing.new_test_session('$vargs $tool_args', false) diff --git a/cmd/tools/vtracev.v b/cmd/tools/vtracev.v index 16661881ae..801704bf85 100644 --- a/cmd/tools/vtracev.v +++ b/cmd/tools/vtracev.v @@ -6,7 +6,7 @@ import v.pref fn main() { vexe := pref.vexe_path() vroot := os.dir(vexe) - os.chdir(vroot) + os.chdir(vroot) ? os.setenv('VCOLORS', 'always', true) self_idx := os.args.index('tracev') args := os.args[1..self_idx] diff --git a/examples/dynamic_library_loading/use_test.v b/examples/dynamic_library_loading/use_test.v index 9a93d66b3c..a224b2adaf 100644 --- a/examples/dynamic_library_loading/use_test.v +++ b/examples/dynamic_library_loading/use_test.v @@ -21,14 +21,14 @@ fn test_vexe() { } fn test_can_compile_library() { - os.chdir(cfolder) + os.chdir(cfolder) or {} os.rm(library_file_name) or {} v_compile('-d no_backtrace -o library -shared modules/library/library.v') assert os.is_file(library_file_name) } fn test_can_compile_main_program() { - os.chdir(cfolder) + os.chdir(cfolder) or {} assert os.is_file(library_file_name) result := v_compile('run use.v') // dump(result) @@ -37,7 +37,7 @@ fn test_can_compile_main_program() { } fn test_can_compile_and_use_library_with_skip_unused() { - os.chdir(cfolder) + os.chdir(cfolder) or {} os.rm(library_file_name) or {} v_compile('-skip-unused -d no_backtrace -o library -shared modules/library/library.v') assert os.is_file(library_file_name)