From f388f9872ad4f023e04dd1c7f19d48118b39fecf Mon Sep 17 00:00:00 2001 From: zhanghuanhuan Date: Wed, 14 Jun 2023 13:50:12 +0800 Subject: [PATCH] refactor: add rust framework for builtins. --- bash-5.1/.gitignore | 1 - bash-5.1/Cargo.toml | 8 +------- bash-5.1/configure | 3 +-- bash-5.1/execute_cmd.c | 5 +---- record.txt | 1 + 5 files changed, 4 insertions(+), 14 deletions(-) diff --git a/bash-5.1/.gitignore b/bash-5.1/.gitignore index 4c50e886..6c7dbc5f 100644 --- a/bash-5.1/.gitignore +++ b/bash-5.1/.gitignore @@ -1,5 +1,4 @@ *.swp tags -Cargo.lock target/ .vscode diff --git a/bash-5.1/Cargo.toml b/bash-5.1/Cargo.toml index 6e02f0ac..ec2f4f94 100644 --- a/bash-5.1/Cargo.toml +++ b/bash-5.1/Cargo.toml @@ -2,17 +2,11 @@ name = "rsbash" version = "0.1.0" edition = "2021" -[lib] -name = "rsbash" -crate-type = ["cdylib"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace] -members = ["builtins_rust/read", "builtins/command1", "builtins/command2", "builtins_rust/common"] +members = ["builtins/command1", "builtins/command2"] [dependencies] -libc = "0.2" command1 = {path = "./builtins/command1"} command2 = {path = "./builtins/command2"} -read = {path = "./builtins_rust/read"} -common = {path = "./builtins_rust/common"} diff --git a/bash-5.1/configure b/bash-5.1/configure index 0d917697..0f1d3ed1 100755 --- a/bash-5.1/configure +++ b/bash-5.1/configure @@ -4231,7 +4231,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$want_auto_cflags"; then AUTO_CFLAGS="-g ${GCC+-O2}" AUTO_LDFLAGS="-g ${GCC+-O2}" - STYLE_CFLAGS="${GCC+-Wno-parentheses} ${GCC+-Wno-format-security} ${GCC+-fPIC}" + STYLE_CFLAGS="${GCC+-Wno-parentheses} ${GCC+-Wno-format-security}" else AUTO_CFLAGS= AUTO_LDFLAGS= STYLE_CFLAGS= fi @@ -20255,7 +20255,6 @@ fi $as_echo "using $bash_cv_termcap_lib" >&6; } if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then LDFLAGS="$LDFLAGS -L./lib/termcap" - TERMCAP_LIB="./lib/termcap/libtermcap.a" TERMCAP_DEP="./lib/termcap/libtermcap.a" elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then diff --git a/bash-5.1/execute_cmd.c b/bash-5.1/execute_cmd.c index 9d66af0b..c86c1a07 100644 --- a/bash-5.1/execute_cmd.c +++ b/bash-5.1/execute_cmd.c @@ -110,8 +110,6 @@ extern int errno; # include /* mbschr */ #endif -# include "./rsbuiltins.h" - extern int command_string_index; extern char *the_printed_command; extern time_t shell_start_time; @@ -4737,7 +4735,6 @@ execute_builtin (builtin, words, flags, subshell) error_trap = 0; should_keep = 0; - //r_execute_cmd(); /* The eval builtin calls parse_and_execute, which does not know about the setting of flags, and always calls the execution functions with flags that will exit the shell on an error if -e is set. If the @@ -4841,7 +4838,6 @@ execute_builtin (builtin, words, flags, subshell) executing_builtin++; executing_command_builtin |= builtin == command_builtin; result = ((*builtin) (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. */ @@ -5312,6 +5308,7 @@ execute_builtin_or_function (words, builtin, var, redirects, int ofifo, nfifo, osize; void *ofifo_list; #endif + #if defined (PROCESS_SUBSTITUTION) begin_unwind_frame ("saved_fifos"); /* If we return, we longjmp and don't get a chance to restore the old diff --git a/record.txt b/record.txt index b83bdb14..97b3d1a5 100644 --- a/record.txt +++ b/record.txt @@ -12,3 +12,4 @@ 12 13 14 +15 -- Gitee