diff --git a/bash-5.1/r_execute_cmd/src/lib.rs b/bash-5.1/r_execute_cmd/src/lib.rs index d0c0ae5ce4b5021193afe40c537b13fbfe39c25c..47e52a310d46b781e8e76742dde2fe79b0605493 100644 --- a/bash-5.1/r_execute_cmd/src/lib.rs +++ b/bash-5.1/r_execute_cmd/src/lib.rs @@ -5078,8 +5078,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 + } + }; +}