From 51d339a3c2a0640dc4838d2ddbe59021fdcb578a Mon Sep 17 00:00:00 2001 From: zhanghuanhuan Date: Fri, 10 Nov 2023 16:58:34 +0800 Subject: [PATCH] add really_munge_braces func for bracecomp file --- bash-5.1/r_variables/src/lib.rs | 84 +++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/bash-5.1/r_variables/src/lib.rs b/bash-5.1/r_variables/src/lib.rs index cb0e1fe..68343ff 100644 --- a/bash-5.1/r_variables/src/lib.rs +++ b/bash-5.1/r_variables/src/lib.rs @@ -134,6 +134,52 @@ macro_rules! vc_istempenv { } } +#[macro_export] +macro_rules! FV_NODYNAMIC { + () => { + 0x04 + }; +} + +#[macro_export] +macro_rules! EXECUTION_FAILURE { + () => { + 1 as libc::c_int + }; +} + + +#[macro_export] +macro_rules! DEFAULT_PATH_VALUE { + () => { + b"/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:.\0" + as *const u8 as *const libc::c_char as *mut libc::c_char + } +} + +#[no_mangle] +pub static mut nameref_invalid_value: SHELL_VAR = SHELL_VAR { + + name: 0 as *const libc::c_char as *mut libc::c_char, + value: 0 as *const libc::c_char as *mut libc::c_char, + exportstr: 0 as *const libc::c_char as *mut libc::c_char, + dynamic_value: None, + assign_func: None, + attributes: 0, + context: 0, + +}; + +static mut nameref_maxloop_value: SHELL_VAR = SHELL_VAR { + name: 0 as *const libc::c_char as *mut libc::c_char, + value: 0 as *const libc::c_char as *mut libc::c_char, + exportstr: 0 as *const libc::c_char as *mut libc::c_char, + dynamic_value: None, + assign_func: None, + attributes: 0, + context: 0, +}; + static mut last_table_searched: *mut HASH_TABLE = 0 as *const HASH_TABLE as *mut HASH_TABLE; @@ -166,3 +212,41 @@ unsafe extern "C" fn create_variable_tables() { shell_function_defs = hash_create(FUNCTIONS_HASH_BUCKETS!() as libc::c_int); } } + + +unsafe extern "C" fn set_machine_vars() { + + let mut temp_var: *mut SHELL_VAR = 0 as *mut SHELL_VAR; + //set_if_not 下文会实现 + temp_var = set_if_not( + b"HOSTTYPE\0" as *const u8 as *const libc::c_char as *mut libc::c_char, + get_host_type() as *mut libc::c_char + ); + + temp_var = set_if_not( + b"OSTYPE\0" as *const u8 as *const libc::c_char as *mut libc::c_char, + get_os_type() as *mut libc::c_char + ); + + temp_var = set_if_not( + b"MACHTYPE\0" as *const u8 as *const libc::c_char as *mut libc::c_char, + get_mach_type() as *mut libc::c_char + ); + + temp_var = set_if_not( + b"HOSTNAME\0" as *const u8 as *const libc::c_char as *mut libc::c_char, + current_host_name + ); + + +} + +#[no_mangle] +pub unsafe extern "C" fn sh_get_home_dir() -> *mut libc::c_char { + + if (current_user.home_dir).is_null() { + // get_current_user_info in file of shell.c + get_current_user_info(); + } + return current_user.home_dir; +} -- Gitee