mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os.exec: on unix return error, when the command was not found, instead of os.Result
This commit is contained in:
parent
c261408f54
commit
ab7936f514
@ -148,9 +148,9 @@ pub fn exec(cmd string) ?Result {
|
|||||||
soutput := res.str()
|
soutput := res.str()
|
||||||
// res.free()
|
// res.free()
|
||||||
exit_code := vpclose(f)
|
exit_code := vpclose(f)
|
||||||
// if exit_code != 0 {
|
if exit_code == 127 {
|
||||||
// return error(res)
|
return error_with_code(soutput, 127)
|
||||||
// }
|
}
|
||||||
return Result{
|
return Result{
|
||||||
exit_code: exit_code
|
exit_code: exit_code
|
||||||
output: soutput
|
output: soutput
|
||||||
|
@ -241,13 +241,15 @@ pub fn exec(cmd string) ?Result {
|
|||||||
create_pipe_ok := C.CreatePipe(voidptr(&child_stdout_read),
|
create_pipe_ok := C.CreatePipe(voidptr(&child_stdout_read),
|
||||||
voidptr(&child_stdout_write), voidptr(&sa), 0)
|
voidptr(&child_stdout_write), voidptr(&sa), 0)
|
||||||
if !create_pipe_ok {
|
if !create_pipe_ok {
|
||||||
error_msg := get_error_msg(int(C.GetLastError()))
|
error_num := int(C.GetLastError())
|
||||||
return error('exec failed (CreatePipe): $error_msg')
|
error_msg := get_error_msg(error_num)
|
||||||
|
return error_with_code('exec failed (CreatePipe): $error_msg', error_num)
|
||||||
}
|
}
|
||||||
set_handle_info_ok := C.SetHandleInformation(child_stdout_read, C.HANDLE_FLAG_INHERIT, 0)
|
set_handle_info_ok := C.SetHandleInformation(child_stdout_read, C.HANDLE_FLAG_INHERIT, 0)
|
||||||
if !set_handle_info_ok {
|
if !set_handle_info_ok {
|
||||||
error_msg := get_error_msg(int(C.GetLastError()))
|
error_num := int(C.GetLastError())
|
||||||
panic('exec failed (SetHandleInformation): $error_msg')
|
error_msg := get_error_msg(error_num)
|
||||||
|
return error_with_code('exec failed (SetHandleInformation): $error_msg', error_num)
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_info := ProcessInformation{}
|
proc_info := ProcessInformation{}
|
||||||
@ -267,7 +269,7 @@ pub fn exec(cmd string) ?Result {
|
|||||||
if !create_process_ok {
|
if !create_process_ok {
|
||||||
error_num := int(C.GetLastError())
|
error_num := int(C.GetLastError())
|
||||||
error_msg := get_error_msg(error_num)
|
error_msg := get_error_msg(error_num)
|
||||||
return error('exec failed (CreateProcess) with code $error_num: $error_msg cmd: $cmd')
|
return error_with_code('exec failed (CreateProcess) with code $error_num: $error_msg cmd: $cmd', error_num)
|
||||||
}
|
}
|
||||||
C.CloseHandle(child_stdin)
|
C.CloseHandle(child_stdin)
|
||||||
C.CloseHandle(child_stdout_write)
|
C.CloseHandle(child_stdout_write)
|
||||||
|
Loading…
Reference in New Issue
Block a user