diff --git a/bash-5.1/builtins_rust/common/src/lib.rs b/bash-5.1/builtins_rust/common/src/lib.rs index 696f3bcbe3e5a857c4c702a9ba73adabddae76b6..332e7e23de0a71579f449bb62c962ac2bc30a414 100644 --- a/bash-5.1/builtins_rust/common/src/lib.rs +++ b/bash-5.1/builtins_rust/common/src/lib.rs @@ -1757,7 +1757,7 @@ pub extern "C" fn r_builtin_unbind_variable(vname:*const c_char)->i32{ pub extern "C" fn get_local_str()-> Vec{ let lang : String; - match var("LANGUAGE") { + match var("LANG") { Ok(v) => lang = v , Err(e) => { @@ -1767,7 +1767,8 @@ pub extern "C" fn get_local_str()-> Vec{ } // println!("now language is {:?}",lang); //parse() 用于类型转换 - let langid : LanguageIdentifier = lang.parse().expect("wrong language"); + let v: Vec<_> = lang.split('.').collect(); + let langid : LanguageIdentifier = v[0].parse().expect("wrong language"); let locales = vec![langid.into()]; return locales; } diff --git a/bash-5.1/builtins_rust/exec_cmd/src/lib.rs b/bash-5.1/builtins_rust/exec_cmd/src/lib.rs index ad9fc7066ba85fda35bb67c6b9606c177c4d8981..23bb0478f51e813e4c4fec98b417d6c088ddd2e0 100644 --- a/bash-5.1/builtins_rust/exec_cmd/src/lib.rs +++ b/bash-5.1/builtins_rust/exec_cmd/src/lib.rs @@ -23,6 +23,7 @@ use rhash::r_hash_builtin; use rhelp::r_help_builtin; use rhistory::r_history_builtin; use rjobs::r_jobs_builtin; +use rjobs::r_disown_builtin; use rkill::r_kill_builtin; use rmapfile::r_mapfile_builtin; use rprintf::r_printf_builtin; @@ -105,7 +106,8 @@ enum CMDType { TypeCmd, UlimitCmd, UmaskCmd, - WaitCmd + WaitCmd, + DisownCmd } struct AliasComand ; @@ -496,6 +498,15 @@ impl CommandExec for UnSetComand{ } } + struct DisownCommand ; + impl CommandExec for DisownCommand{ + fn excute(&self,list : *mut WordList)-> i32{ + unsafe { + r_disown_builtin(list) + } + } + } + // 定义接口 pub trait CommandExec { fn excute(&self,list : *mut WordList) -> i32; @@ -690,6 +701,9 @@ impl Factory for SimpleFactory { ), CMDType::WaitCmd => Box::new( WaitComand{} + ), + CMDType::DisownCmd => Box::new( + DisownCommand{} ) } } @@ -892,6 +906,9 @@ unsafe fn get_cmd_type (command : *mut libc::c_char) -> CMDType{ else if libc::strcmp(command , b"wait\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { types = CMDType::WaitCmd; } + else if libc::strcmp(command , b"disown\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 { + types = CMDType::DisownCmd; + } types } diff --git a/bash-5.1/builtins_rust/help/src/lib.rs b/bash-5.1/builtins_rust/help/src/lib.rs index e4b9f7b0600c3ba5fbf879cbb027ad678b5e992b..a5512bab8acc229cdbf0e7bce5cec506059ec63e 100644 --- a/bash-5.1/builtins_rust/help/src/lib.rs +++ b/bash-5.1/builtins_rust/help/src/lib.rs @@ -305,7 +305,7 @@ fn open_helpfile(name :*mut c_char) -> i32{ fn show_longdoc(i : i32){ let builtin1 = unsafe{&(*((shell_builtins as usize + (i*BUILTIN_SIZEOF!()) as usize) as *mut builtin))}; - let mgr = ResourceManager::new("./resources/{locale}/{res_id}".into()); + let mgr = ResourceManager::new("/usr/share/utshell/resources/{locale}/{res_id}".into()); let resources = vec![ "message.ftl".into()]; let mut args = FluentArgs::new(); let c_str: &CStr = unsafe { CStr::from_ptr(builtin1.name) }; diff --git a/bash-5.1/builtins_rust/jobs/src/lib.rs b/bash-5.1/builtins_rust/jobs/src/lib.rs index 18e88ec748436d30ee9a3e84be4c6f8122f2256e..d16b8941c3ef2b050e444c3c72a4e74f859217a3 100644 --- a/bash-5.1/builtins_rust/jobs/src/lib.rs +++ b/bash-5.1/builtins_rust/jobs/src/lib.rs @@ -330,14 +330,18 @@ macro_rules! CMD_INHIBIT_EXPANSION {/* Do not expand the command words. */ #[macro_export] macro_rules! get_job_by_jid { ($ind:expr) => { + //(*((jobs as usize + ($ind*8) as usize ) as *mut*mut JOB) as *mut JOB) + //println!("====jobs.offset={:?}", (*jobs.offset($ind as isize))); + //(*((*jobs.offset($ind)) as *mut *mut JOB) as *mut JOB) (*((jobs as usize + ($ind*8) as usize ) as *mut*mut JOB) as *mut JOB) + } } #[macro_export] macro_rules! INVALID_JOB { ($j:expr) => { - $j <0 || $j >= js.j_jobslots || get_job_by_jid !($j) == std::ptr::null_mut() + $j <0 || $j >= js.j_jobslots || get_job_by_jid!($j) == std::ptr::null_mut() } } @@ -390,7 +394,7 @@ extern "C" { } libc::free((*(*l).word).word as * mut libc::c_void); - (*(*(*l).word).word) = (*get_job_by_jid! (job)).pgrp as libc::c_char; + (*(*(*l).word).word) = (*get_job_by_jid!(job)).pgrp as libc::c_char; } l=(*l).next; } @@ -484,7 +488,7 @@ pub extern "C" fn r_jobs_builtin(mut list:*mut WordList)->i32 { BLOCK_CHILD !(Some(&mut set), Some(&mut oset)); job = get_job_spec (list); - if (job == NO_JOB!()) || jobs == std::ptr::null_mut() || get_job_by_jid !(job) == std::ptr::null_mut() { + if (job == NO_JOB!()) || jobs == std::ptr::null_mut() || get_job_by_jid!(job) == std::ptr::null_mut() { sh_badjob ((*((*list).word)).word); any_failed+=1; } else if job != DUP_JOB!() { @@ -547,14 +551,13 @@ pub extern "C" fn r_disown_builtin (list:* mut WordList)->libc::c_int { } return EXECUTION_SUCCESS!(); } - BLOCK_CHILD !(Some(&mut set), Some(&mut oset)); if (loptend !=std::ptr::null_mut() && legal_number ((*(*loptend).word).word, &mut pid_value) !=0 && pid_value == pid_value) { job=get_job_by_pid ( pid_value as i32, 0, 0 as *mut*mut PROCESS); }else { - get_job_spec (loptend); + job = get_job_spec (loptend); } - if job == NO_JOB!() || jobs !=std::ptr::null_mut() || INVALID_JOB!(job) { + if (job == NO_JOB!()) ||( jobs ==std::ptr::null_mut()) || (INVALID_JOB!(job)) { if loptend !=std::ptr::null_mut() { sh_badjob ((*(*loptend).word).word); } else { diff --git a/bash-5.1/builtins_rust/umask/src/lib.rs b/bash-5.1/builtins_rust/umask/src/lib.rs index 399070d0153136d4ca5cf95ea218c55c50c8dc34..5ad75042953e863e2a8b830c4ed2a212362d6692 100644 --- a/bash-5.1/builtins_rust/umask/src/lib.rs +++ b/bash-5.1/builtins_rust/umask/src/lib.rs @@ -247,7 +247,15 @@ pub extern "C" fn r_umask_builtin(mut list:*mut WordList) ->i32{ else{ /* Display the UMASK for this user. */ umask_arg = umask(0o22); umask(umask_arg); - + if pflag != 0{ + if print_symbolically != 0{ + println!("umask -S"); + } + else{ + print!("umask ") + } + } +/* if pflag != 0{ if print_symbolically != 0{ println!("umask \" -S\" "); @@ -256,7 +264,7 @@ pub extern "C" fn r_umask_builtin(mut list:*mut WordList) ->i32{ println!("umask \"\" ") } } - +*/ if print_symbolically != 0{ r_print_symbolic_umask(umask_arg); } diff --git a/bash-5.1/execute_cmd.c b/bash-5.1/execute_cmd.c index d1a9f1b5d217d7be3e2faf44e54866bafba1b223..b2933f7f0cf5ed34f86f599f0c9893b7b1630a94 100644 --- a/bash-5.1/execute_cmd.c +++ b/bash-5.1/execute_cmd.c @@ -4839,9 +4839,8 @@ execute_builtin (builtin, words, flags, subshell) executing_builtin++; executing_command_builtin |= builtin == command_builtin; - //result = ((*builtin) (words->next)); + // result = ((*builtin) (words->next)); result = r_exec_cmd(words->word->word, words->next); - //r_execute_cmd2(words->next); /* This shouldn't happen, but in case `return' comes back instead of longjmp'ing, we need to unwind. */ @@ -5814,7 +5813,6 @@ shell_execve (command, args, env) char *command; char **args, **env; { - //printf("wwwwwwwwwwwwwwwwwwwwwwwwww===========\n"); int larray, i, fd; char sample[HASH_BANG_BUFSIZ]; int sample_len; diff --git a/record.txt b/record.txt index e8852049677b07dd49010674986e0e62b33a3cf5..a8cd367c329659567d871ed0881c848724a1085d 100644 --- a/record.txt +++ b/record.txt @@ -69,3 +69,11 @@ 68 69 70 +71 +72 +73 +74 +75 +76 +77 +78