diff --git a/bash-5.1/r_execute_cmd/src/lib.rs b/bash-5.1/r_execute_cmd/src/lib.rs index 572d0969c16bddad424b2c4d8e8599a8bda41728..8e2aa199da942ed48f541f02eb8ed74202b11313 100644 --- a/bash-5.1/r_execute_cmd/src/lib.rs +++ b/bash-5.1/r_execute_cmd/src/lib.rs @@ -5054,8 +5054,41 @@ unsafe extern "C" fn execute_builtin( return result; } +unsafe extern "C" fn maybe_restore_getopt_state(mut gs: *mut sh_getopt_state_t) { + if (*gs).gs_flags & 1 != 0 { + sh_getopt_restore_istate(gs); + } else { + free(gs as *mut c_void); + }; +} +#[macro_export] +macro_rules! array_pop { + ($a:expr) => { + array_dispose_element( + array_shift(($a), 1 , 0 ), + ); + }; +} +#[macro_export] +macro_rules! array_cell { + ($var:expr) => { + (*$var).value as *mut ARRAY + }; +} + +#[macro_export] +macro_rules! GET_ARRAY_FROM_VAR { + ($n:expr, $v:expr, $a:expr) => { + $v = find_variable($n); + $a = if !$v.is_null() && array_p!($v) != 0 { + array_cell!($v) + } else { + 0 as *mut ARRAY + } + }; +}