From 8f4efc52b97c174986870f321949694620ba1824 Mon Sep 17 00:00:00 2001 From: wangmengc Date: Mon, 30 Oct 2023 17:53:53 +0800 Subject: [PATCH] add execute shell function function --- bash-5.1/r_execute_cmd/src/lib.rs | 70 +++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/bash-5.1/r_execute_cmd/src/lib.rs b/bash-5.1/r_execute_cmd/src/lib.rs index 5422751..8cdb96d 100644 --- a/bash-5.1/r_execute_cmd/src/lib.rs +++ b/bash-5.1/r_execute_cmd/src/lib.rs @@ -5426,3 +5426,73 @@ unsafe extern "C" fn execute_function( } return result; } + +#[no_mangle] +pub unsafe extern "C" fn execute_shell_function( + mut var: *mut SHELL_VAR, + mut words: *mut WordList, +) -> libc::c_int { + let mut ret: libc::c_int = 0; + let mut bitmap: *mut fd_bitmap = 0 as *mut fd_bitmap; + + bitmap = new_fd_bitmap(FD_BITMAP_DEFAULT_SIZE!()); + begin_unwind_frame( + b"execute-shell-function\0" as *const u8 as *mut libc::c_char, + ); + add_unwind_protect( + transmute::< + unsafe extern "C" fn (fdbp: *mut fd_bitmap), + *mut Function, + >(dispose_fd_bitmap), + bitmap as *mut libc::c_char, + ); + + ret = execute_function( + var, + words, + 0 , + bitmap, + 0 , + 0 , + ); + + dispose_fd_bitmap(bitmap); + discard_unwind_frame( + b"execute-shell-function\0" as *const u8 as *const libc::c_char + as *mut libc::c_char, + ); + return ret; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- Gitee