From 3aec0ec30fe33bb55c0f98fda8c0db392a1eb403 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Tue, 19 Jan 2021 17:12:43 -0500 Subject: [PATCH] commit bash-20210115 snapshot --- CWRU/CWRU.chlog | 36 ++++++++++++++++++ MANIFEST | 1 + Makefile.in | 2 +- lib/readline/bind.c | 15 ++++---- lib/readline/misc.c | 4 +- lib/readline/readline.c | 28 +++++++++----- lib/sh/winsize.c | 8 +++- support/Makefile.in | 2 +- tests/RUN-ONE-TEST | 2 +- tests/nameref.right | 31 ++++++++++++++++ tests/nameref23.sub | 82 +++++++++++++++++++++++++++++++++++++++++ 11 files changed, 187 insertions(+), 24 deletions(-) create mode 100644 tests/nameref23.sub diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 8580d399..9c148c0c 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -9341,3 +9341,39 @@ findcmd.c lib/sh/winsize.c - get_new_window_size: set *rp and *cp even if READLINE is not defined + + 1/15 + ---- +lib/sh/winsize.c + - get_new_window_size: call rl_set_window_size only if we can determine + we're using readline: an interactive shell without no-line-editing, + or if we've already initialized readline, presumably in a non- + interactive shell + +support/Makefile.in + - man2html: add LDFLAGS_FOR_BUILD to the recipe. Report from + Jeffrey Walton + + 1/17 + ---- +lib/readline/misc.c + - rl_operate_and_get_next: fix old K&R function declaration. Report + from Tom Tromey + +lib/readline/readline.c + - _rl_internal_char_cleanup: move code that cleans up the active region + and deactivates the mark inside this function so callback mode + applications get the intended functionality. Report and fix from + sparrowhawk996@gmail.com + +lib/readline/bind.c + - rl_parse_and_bind: when using the arithmetic comparison operators on + the version, make sure to invert the tests so that we stop parsing + if the test fails. Report and fix from Tom Tromey + + 1/19 + ---- +Makefile.in + - pipesize.h: add dependency on ${BUILTINS_LIBRARY} to avoid parallel + makes trying to create it twice. Report and fix from + Richard Purdie diff --git a/MANIFEST b/MANIFEST index 7a73554f..9a12cc9f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1215,6 +1215,7 @@ tests/nameref19.sub f tests/nameref20.sub f tests/nameref21.sub f tests/nameref22.sub f +tests/nameref23.sub f tests/nameref.right f tests/new-exp.tests f tests/new-exp1.sub f diff --git a/Makefile.in b/Makefile.in index 3e3a5d48..fba0ccb2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -746,7 +746,7 @@ ${DEFDIR}/bashgetopt.o: $(BUILTIN_SRCDIR)/bashgetopt.c ${DEFDIR}/builtext.h: $(BUILTIN_DEFS) @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) builtext.h ) || exit 1 -${DEFDIR}/pipesize.h: +${DEFDIR}/pipesize.h: ${BUILTINS_LIBRARY} @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) pipesize.h ) || exit 1 $(SDIR)/man2html$(EXEEXT): ${SUPPORT_SRC}/man2html.c diff --git a/lib/readline/bind.c b/lib/readline/bind.c index 87596dce..76103786 100644 --- a/lib/readline/bind.c +++ b/lib/readline/bind.c @@ -1234,7 +1234,7 @@ parser_if (char *args) #endif /* VI_MODE */ else if (_rl_strnicmp (args, "version", 7) == 0) { - int rlversion, versionarg, op, previ, major, minor; + int rlversion, versionarg, op, previ, major, minor, opresult; _rl_parsing_conditionalized_out = 1; rlversion = RL_VERSION_MAJOR*10 + RL_VERSION_MINOR; @@ -1294,24 +1294,25 @@ parser_if (char *args) switch (op) { case OP_EQ: - _rl_parsing_conditionalized_out = rlversion == versionarg; + opresult = rlversion == versionarg; break; case OP_NE: - _rl_parsing_conditionalized_out = rlversion != versionarg; + opresult = rlversion != versionarg; break; case OP_GT: - _rl_parsing_conditionalized_out = rlversion > versionarg; + opresult = rlversion > versionarg; break; case OP_GE: - _rl_parsing_conditionalized_out = rlversion >= versionarg; + opresult = rlversion >= versionarg; break; case OP_LT: - _rl_parsing_conditionalized_out = rlversion < versionarg; + opresult = rlversion < versionarg; break; case OP_LE: - _rl_parsing_conditionalized_out = rlversion <= versionarg; + opresult = rlversion <= versionarg; break; } + _rl_parsing_conditionalized_out = 1 - opresult; } /* Check to see if the first word in ARGS is the same as the value stored in rl_readline_name. */ diff --git a/lib/readline/misc.c b/lib/readline/misc.c index 3d9a674c..63fa2ab0 100644 --- a/lib/readline/misc.c +++ b/lib/readline/misc.c @@ -664,15 +664,13 @@ set_saved_history () } int -rl_operate_and_get_next (count, c) - int count, c; +rl_operate_and_get_next (int count, int c) { /* Accept the current line. */ rl_newline (1, c); saved_history_logical_offset = rl_explicit_arg ? count : where_history () + history_base + 1; - _rl_saved_internal_startup_hook = _rl_internal_startup_hook; _rl_internal_startup_hook = set_saved_history; diff --git a/lib/readline/readline.c b/lib/readline/readline.c index e61d188b..e8dbf61d 100644 --- a/lib/readline/readline.c +++ b/lib/readline/readline.c @@ -91,6 +91,8 @@ extern void _rl_parse_colors PARAMS((void)); /* XXX */ static char *readline_internal PARAMS((void)); static void readline_initialize_everything PARAMS((void)); +static void run_startup_hooks PARAMS((void)); + static void bind_arrow_keys_internal PARAMS((Keymap)); static void bind_arrow_keys PARAMS((void)); @@ -403,6 +405,16 @@ readline (const char *prompt) return (value); } +static void +run_startup_hooks (void) +{ + if (rl_startup_hook) + (*rl_startup_hook) (); + + if (_rl_internal_startup_hook) + (*_rl_internal_startup_hook) (); +} + #if defined (READLINE_CALLBACKS) # define STATIC_CALLBACK #else @@ -422,11 +434,7 @@ readline_internal_setup (void) if (_rl_enable_meta & RL_ISSTATE (RL_STATE_TERMPREPPED)) _rl_enable_meta_key (); - if (rl_startup_hook) - (*rl_startup_hook) (); - - if (_rl_internal_startup_hook) - (*_rl_internal_startup_hook) (); + run_startup_hooks (); rl_deactivate_mark (); @@ -511,6 +519,11 @@ readline_internal_teardown (int eof) void _rl_internal_char_cleanup (void) { + if (_rl_keep_mark_active) + _rl_keep_mark_active = 0; + else if (rl_mark_active_p ()) + rl_deactivate_mark (); + #if defined (VI_MODE) /* In vi mode, when you exit insert mode, the cursor moves back over the previous character. We explicitly check for that here. */ @@ -668,11 +681,6 @@ readline_internal_charloop (void) if (rl_pending_input == 0 && lk == _rl_last_command_was_kill) _rl_last_command_was_kill = 0; - if (_rl_keep_mark_active) - _rl_keep_mark_active = 0; - else if (rl_mark_active_p ()) - rl_deactivate_mark (); - _rl_internal_char_cleanup (); #if defined (READLINE_CALLBACKS) diff --git a/lib/sh/winsize.c b/lib/sh/winsize.c index 52ff53d2..846fcd58 100644 --- a/lib/sh/winsize.c +++ b/lib/sh/winsize.c @@ -68,6 +68,11 @@ extern int errno; extern int shell_tty; #if defined (READLINE) +/* Let's not call readline, forcing readline to initialize the termcap/terminfo + variables it needs, unless we have to. */ +extern int interactive_shell; +extern int no_line_editing; +extern int bash_readline_initialized; extern void rl_set_screen_size PARAMS((int, int)); #endif extern void sh_set_lines_and_columns PARAMS((int, int)); @@ -87,7 +92,8 @@ get_new_window_size (from_sig, rp, cp) { sh_set_lines_and_columns (win.ws_row, win.ws_col); #if defined (READLINE) - rl_set_screen_size (win.ws_row, win.ws_col); + if ((interactive_shell && no_line_editing == 0) || bash_readline_initialized) + rl_set_screen_size (win.ws_row, win.ws_col); #endif if (rp) *rp = win.ws_row; diff --git a/support/Makefile.in b/support/Makefile.in index 0289e0ac..f0a17840 100644 --- a/support/Makefile.in +++ b/support/Makefile.in @@ -77,7 +77,7 @@ OBJ1 = man2html.o all: man2html$(EXEEXT) man2html$(EXEEXT): $(OBJ1) - $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) $(OBJ1) -o $@ ${LIBS_FOR_BUILD} + $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(OBJ1) -o $@ ${LIBS_FOR_BUILD} clean: $(RM) man2html$(EXEEXT) $(OBJ1) diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index 0b063810..c8bef8dd 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -1,4 +1,4 @@ -BUILD_DIR=/usr/local/build/chet/bash/bash-current +BUILD_DIR=/usr/local/build/bash/bash-current THIS_SH=$BUILD_DIR/bash PATH=$PATH:$BUILD_DIR diff --git a/tests/nameref.right b/tests/nameref.right index 8fa8211a..7b254ba1 100644 --- a/tests/nameref.right +++ b/tests/nameref.right @@ -510,3 +510,34 @@ declare -a array declare -ai array=([0]="one") declare -a array=([0]="zero") declare -a array=([0]="one" [1]="two" [2]="three") +declare -ai a=([0]="5") +declare -ai a=([0]="6") +declare -ai a=([0]="1") +./nameref23.sub: line 15: declare: b: not found +declare -ai a=([0]="1") +declare -- b="1" +declare -ai a=([0]="1") +declare -- b="11" +declare -ai a=([0]="1") +declare -- b="110" +./nameref23.sub: line 25: declare: `1': invalid variable name for name reference +declare -ai a=([0]="1") +./nameref23.sub: line 27: declare: b: not found +declare -ai a=([0]="4") +declare -in b="a[0]" +declare -ai a=([0]="6") +declare -in b="a[0]" +foo +foo bar +declare -a a=([0]="" [1]="foo bar") +declare -n b="a[1]" +foo +foo bar +declare -a a=([0]="" [1]="foo bar") +declare -n b="a[1]" +12 +16 +declare -ai a=([0]="0" [1]="16") +12 +16 +declare -ai a=([0]="0" [1]="16") diff --git a/tests/nameref23.sub b/tests/nameref23.sub new file mode 100644 index 00000000..358c381e --- /dev/null +++ b/tests/nameref23.sub @@ -0,0 +1,82 @@ +declare -ai a +a[0]=4 +declare -n b='a[0]' + +b+=1 ; declare -p a + +declare b+=1 ; declare -p a + +unset a b +unset -n b + +###### +declare -ai a=(1) +declare -in b="a[0]" +declare -p a b + +b+=1 ; declare -p a b +b+=1 ; declare -p a b +b+=0 ; declare -p a b + +unset a b + +##### +declare -ai a=(1) +declare -n b="1" +declare -p a +declare -np b + +unset a ; unset -n b + +##### +declare -ai a=('4'); +declare -n b='a[0]'; +declare -ni b; # this should maybe not be allowed, but it is for now +declare -p a b + +b+=2; +declare -p a b + +unset a ; unset -n b + +##### +f() +{ + local -a a=('' 'foo'); + local -n b=a[1]; + echo $b; + b+=\ bar; + echo $b; + declare -p a b; +} +f + +declare -a a=('' 'foo'); +declare -n b=a[1]; +echo $b; +b+=\ bar; +echo $b; +declare -p a b + +unset a ; unset -n b + +unset -f f +f() +{ + local -ai a=(0 12); + local -n b=a[1]; + echo $b; + b+=4; + echo $b; + declare -p a; +} +f + +declare -ai a=(0 12); +declare -n b=a[1]; +echo $b; +b+=4; +echo $b; +declare -p a + +unset a ; unset -n b