diff --git a/vlib/os/os.v b/vlib/os/os.v index ed5009c4f8..3399c3ecff 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -375,6 +375,9 @@ fn executable_fallback() string { // find_exe_path walks the environment PATH, just like most shell do, it returns // the absolute path of the executable if found pub fn find_abs_path_of_executable(exepath string) ?string { + if exepath == '' { + return error('expected non empty `exepath`') + } if is_abs_path(exepath) { return real_path(exepath) } diff --git a/vlib/os/os_test.v b/vlib/os/os_test.v index cface1ebf7..b055263f74 100644 --- a/vlib/os/os_test.v +++ b/vlib/os/os_test.v @@ -543,3 +543,12 @@ fn test_posix_set_bit() { rm(fpath) or {} } } + +fn test_exists_in_system_path() { + assert os.exists_in_system_path('') == false + $if windows { + assert os.exists_in_system_path('cmd') == true + return + } + assert os.exists_in_system_path('ls') == true +}