commit bash-20200403 snapshot

This commit is contained in:
Chet Ramey
2020-04-06 09:52:11 -04:00
parent e2e18b720b
commit e34adc2c3b
17 changed files with 672 additions and 814 deletions
+74
View File
@@ -7788,3 +7788,77 @@ execute_cmd.c
<valentin.lab@kalysto.org> <valentin.lab@kalysto.org>
- execute_command_internal,execute_builtin_or_function: ofifo_list is - execute_command_internal,execute_builtin_or_function: ofifo_list is
now a void * instead of a char * now a void * instead of a char *
3/30
----
lib/readline/{terminal.c,rlprivate.h}
- _rl_standout_{on,off}: new functions, to enter and exit terminal
standout mode
lib/readline/rlprivate.h
- _rl_refresh_line: new extern declaration
lib/readline/display.c
- visible and invisible lines: added members to deal with tracking the
`current face'
- realloc_line: broke code to manage visible_line and invisible_line
allocation out of init_line_structures, added code to manage arrays
of visible and invisible line face info per character
- invis_{addc,adds,nul}: new functions to add characters to the
invisible line and keep the invisible face data updated with whatever
the current face is
- set_active_region: keep track of the display region that should be
in standout mode
- rl_redisplay: use invis_addc/adds/nul to update the invisible line
buffer instead of modifying invisible_line directly
- _rl_refresh_line: moved body of function here from text.c
lib/readline/text.c
- rl_refresh_line: now just calls _rl_refresh_line and marks the display
as fixed
3/31
----
variables.c
- bind_variable_internal: dynamic variables with assignment functions
now honor the readonly attribute by giving an error. Fixes issue
reported by Rob Landley <rob@landley.net>
- assign_seconds: allow seconds to be assigned using an arithmetic
expression
- assign_random: allow RANDOM to be assigned using an arithmetic
expression
doc/{bash.1,bashref.texi}
- HISTCMD: note that assignments to HISTCMD have no effect
4/2
---
execute_cmd.c
- execute_in_subshell: make sure we note that we're not reading our
command input from a buffered stream any more, so we don't
sync the buffered stream backwards in subsequent commands this
subshell runs. Fixes bug reported by OÄuz <oguzismailuysal@gmail.com>
4/3
---
builtins/read.def
- read_builtin: if a read in posix mode is interrupted by a signal,
make sure to preserve the value of errno around calls to
check_signals and run_pending_traps so any error message isn't quite
as confusing. Issue reported by Stan Marsh <gazelle@xmission.com>
lib/sh/zread.c
- zread: preserve value of errno (always EINTR) around calls to
check_signals or check_signals_and_traps
trap.c
- run_debug_trap: allow suppress_debug_trap_verbose being set to
turn off `set -v' temporarily while executing the DEBUG trap (if
it's set)
builtins/fc.def
- set suppress_debug_trap_verbose so set -v won't be in effect while
the DEBUG trap runs. Most recently reported by Ami Fischman
<ami@fischman.org>; originally raised by Boruch Baum
<boruch_baum@gmx.com> back in 10/2017
+14 -10
View File
@@ -1,7 +1,7 @@
This file is fc.def, from which is created fc.c. This file is fc.def, from which is created fc.c.
It implements the builtin "fc" in Bash. It implements the builtin "fc" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc. Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell. This file is part of GNU Bash, the Bourne Again SHell.
@@ -86,9 +86,11 @@ $END
extern int errno; extern int errno;
#endif /* !errno */ #endif /* !errno */
extern int unlink __P((const char *)); extern int unlink PARAMS((const char *));
extern FILE *sh_mktmpfp __P((char *, int, char **)); extern FILE *sh_mktmpfp PARAMS((char *, int, char **));
extern int suppress_debug_trap_verbose;
/* **************************************************************** */ /* **************************************************************** */
/* */ /* */
@@ -144,14 +146,14 @@ typedef struct repl {
} \ } \
} while (0) } while (0)
static char *fc_dosubs __P((char *, REPL *)); static char *fc_dosubs PARAMS((char *, REPL *));
static char *fc_gethist __P((char *, HIST_ENTRY **)); static char *fc_gethist PARAMS((char *, HIST_ENTRY **));
static int fc_gethnum __P((char *, HIST_ENTRY **)); static int fc_gethnum PARAMS((char *, HIST_ENTRY **));
static int fc_number __P((WORD_LIST *)); static int fc_number PARAMS((WORD_LIST *));
static void fc_replhist __P((char *)); static void fc_replhist PARAMS((char *));
#ifdef INCLUDE_UNUSED #ifdef INCLUDE_UNUSED
static char *fc_readline __P((FILE *)); static char *fc_readline PARAMS((FILE *));
static void fc_addhist __P((char *)); static void fc_addhist PARAMS((char *));
#endif #endif
static void static void
@@ -470,7 +472,9 @@ fc_builtin (list)
add_unwind_protect (xfree, fn); add_unwind_protect (xfree, fn);
add_unwind_protect (unlink, fn); add_unwind_protect (unlink, fn);
add_unwind_protect (set_verbose_flag, (char *)NULL); add_unwind_protect (set_verbose_flag, (char *)NULL);
unwind_protect_int (suppress_debug_trap_verbose);
echo_input_at_read = 1; echo_input_at_read = 1;
suppress_debug_trap_verbose = 1;
retval = fc_execute_file (fn); retval = fc_execute_file (fn);
run_unwind_frame ("fc builtin"); run_unwind_frame ("fc builtin");
+5
View File
@@ -604,6 +604,7 @@ read_builtin (list)
reading = 1; reading = 1;
CHECK_ALRM; CHECK_ALRM;
errno = 0;
if (unbuffered_read == 2) if (unbuffered_read == 2)
retval = posixly_correct ? zreadintr (fd, &c, 1) : zreadn (fd, &c, nchars - nr); retval = posixly_correct ? zreadintr (fd, &c, 1) : zreadn (fd, &c, nchars - nr);
else if (unbuffered_read) else if (unbuffered_read)
@@ -614,6 +615,9 @@ read_builtin (list)
if (retval <= 0) if (retval <= 0)
{ {
int t;
t = errno;
if (retval < 0 && errno == EINTR) if (retval < 0 && errno == EINTR)
{ {
check_signals (); /* in case we didn't call zread via zreadc */ check_signals (); /* in case we didn't call zread via zreadc */
@@ -628,6 +632,7 @@ read_builtin (list)
ttyrestore (&termsave); /* fix terminal before exiting */ ttyrestore (&termsave); /* fix terminal before exiting */
CHECK_TERMSIG; CHECK_TERMSIG;
eof = 1; eof = 1;
errno = t; /* preserve it for the error message below */
break; break;
} }
+4
View File
@@ -1819,6 +1819,10 @@ subsequently reset.
.B HISTCMD .B HISTCMD
The history number, or index in the history list, of the current The history number, or index in the history list, of the current
command. command.
Assignments to
.SM
.B HISTCMD
are ignored.
If If
.SM .SM
.B HISTCMD .B HISTCMD
+1
View File
@@ -6081,6 +6081,7 @@ parser to treat the rest of the line as a comment.
@item HISTCMD @item HISTCMD
The history number, or index in the history list, of the current The history number, or index in the history list, of the current
command. command.
Assignments to @env{HISTCMD} are ignored.
If @env{HISTCMD} If @env{HISTCMD}
is unset, it loses its special properties, is unset, it loses its special properties,
even if it is subsequently reset. even if it is subsequently reset.
+11
View File
@@ -1518,6 +1518,7 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
QUIT; QUIT;
CHECK_TERMSIG; CHECK_TERMSIG;
CHECK_SIGTERM; /* after RESET_SIGTERM in make_child */
reset_terminating_signals (); /* in sig.c */ reset_terminating_signals (); /* in sig.c */
/* Cancel traps, in trap.c. */ /* Cancel traps, in trap.c. */
@@ -1592,6 +1593,11 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
if (should_redir_stdin && stdin_redir == 0) if (should_redir_stdin && stdin_redir == 0)
async_redirect_stdin (); async_redirect_stdin ();
#if defined (BUFFERED_INPUT)
/* In any case, we are not reading our command input from stdin. */
default_buffered_input = -1;
#endif
#if 0 /* XXX - TAG:bash-5.1 */ #if 0 /* XXX - TAG:bash-5.1 */
if (user_subshell && command->type == cm_subshell) if (user_subshell && command->type == cm_subshell)
optimize_subshell_command (command->value.Subshell->command); optimize_subshell_command (command->value.Subshell->command);
@@ -4359,7 +4365,12 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
/* In POSIX mode, assignment errors in the temporary environment cause a /* In POSIX mode, assignment errors in the temporary environment cause a
non-interactive shell to exit. */ non-interactive shell to exit. */
#if 1
if (posixly_correct && builtin_is_special && interactive_shell == 0 && tempenv_assign_error) if (posixly_correct && builtin_is_special && interactive_shell == 0 && tempenv_assign_error)
#else
/* This is for strict posix conformance. */
if (posixly_correct && interactive_shell == 0 && tempenv_assign_error)
#endif
{ {
last_command_exit_value = EXECUTION_FAILURE; last_command_exit_value = EXECUTION_FAILURE;
jump_to_top_level (ERREXIT); jump_to_top_level (ERREXIT);
+3 -3
View File
@@ -4100,9 +4100,9 @@ set_job_status_and_cleanup (job)
/* If the signal is trapped, let the trap handler get it no matter /* If the signal is trapped, let the trap handler get it no matter
what and simply return if the trap handler returns. what and simply return if the trap handler returns.
maybe_call_trap_handler() may cause dead jobs to be removed from maybe_call_trap_handler() may cause dead jobs to be removed from
the job table because of a call to execute_command. We work the job table because of a call to execute_command. We work
around this by setting JOBS_LIST_FROZEN. */ around this by setting JOBS_LIST_FROZEN. */
old_frozen = jobs_list_frozen; old_frozen = jobs_list_frozen;
jobs_list_frozen = 1; jobs_list_frozen = 1;
tstatus = maybe_call_trap_handler (SIGINT); tstatus = maybe_call_trap_handler (SIGINT);
+141 -80
View File
@@ -1,6 +1,6 @@
/* display.c -- readline redisplay facility. */ /* display.c -- readline redisplay facility. */
/* Copyright (C) 1987-2019 Free Software Foundation, Inc. /* Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@@ -70,6 +70,7 @@ static void insert_some_chars PARAMS((char *, int, int));
static void open_some_spaces PARAMS((int)); static void open_some_spaces PARAMS((int));
static void cr PARAMS((void)); static void cr PARAMS((void));
static void redraw_prompt PARAMS((char *)); static void redraw_prompt PARAMS((char *));
static void _rl_move_cursor_relative PARAMS((int, const char *));
/* Values for FLAGS */ /* Values for FLAGS */
#define PMT_MULTILINE 0x01 #define PMT_MULTILINE 0x01
@@ -82,6 +83,7 @@ static char *expand_prompt PARAMS((char *, int, int *, int *, int *, int *));
struct line_state struct line_state
{ {
char *line; char *line;
char *lface;
int *lbreaks; int *lbreaks;
int lbsize; int lbsize;
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
@@ -104,7 +106,9 @@ static int line_structures_initialized = 0;
#define vis_lbsize (line_state_visible->lbsize) #define vis_lbsize (line_state_visible->lbsize)
#define visible_line (line_state_visible->line) #define visible_line (line_state_visible->line)
#define vis_face (line_state_visible->lface)
#define invisible_line (line_state_invisible->line) #define invisible_line (line_state_invisible->line)
#define inv_face (line_state_invisible->lface)
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
static int _rl_col_width PARAMS((const char *, int, int, int)); static int _rl_col_width PARAMS((const char *, int, int, int));
@@ -125,6 +129,10 @@ static int _rl_col_width PARAMS((const char *, int, int, int));
to use prompt_last_invisible directly. */ to use prompt_last_invisible directly. */
#define PROMPT_ENDING_INDEX \ #define PROMPT_ENDING_INDEX \
((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1) ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1)
#define FACE_NORMAL '0'
#define FACE_STANDOUT '1'
#define FACE_INVALID ((char)1)
/* **************************************************************** */ /* **************************************************************** */
/* */ /* */
@@ -223,7 +231,7 @@ static int msg_bufsiz = 0;
static int forced_display; static int forced_display;
/* Default and initial buffer size. Can grow. */ /* Default and initial buffer size. Can grow. */
static int line_size = DEFAULT_LINE_BUFFER_SIZE; static int line_size = 0;
/* Set to a non-zero value if horizontal scrolling has been enabled /* Set to a non-zero value if horizontal scrolling has been enabled
automatically because the terminal was resized to height 1. */ automatically because the terminal was resized to height 1. */
@@ -602,6 +610,42 @@ rl_expand_prompt (char *prompt)
} }
} }
/* Allocate the various line structures, making sure they can hold MINSIZE
bytes. If the existing line size can accommodate MINSIZE bytes, don't do
anything. */
static void
realloc_line (int minsize)
{
int minimum_size;
int newsize, delta;
minimum_size = DEFAULT_LINE_BUFFER_SIZE;
if (minsize < minimum_size)
minsize = minimum_size;
if (minsize <= _rl_screenwidth) /* XXX - for gdb */
minsize = _rl_screenwidth + 1;
if (line_size >= minsize)
return;
newsize = minimum_size;
while (newsize < minsize)
newsize *= 2;
visible_line = (char *)xrealloc (visible_line, newsize);
vis_face = (char *)xrealloc (vis_face, newsize);
invisible_line = (char *)xrealloc (invisible_line, newsize);
inv_face = (char *)xrealloc (inv_face, newsize);
delta = newsize - line_size;
memset (visible_line + line_size, 0, delta);
memset (vis_face + line_size, FACE_NORMAL, delta);
memset (invisible_line + line_size, 1, delta);
memset (inv_face + line_size, FACE_INVALID, delta);
line_size = newsize;
}
/* Initialize the VISIBLE_LINE and INVISIBLE_LINE arrays, and their associated /* Initialize the VISIBLE_LINE and INVISIBLE_LINE arrays, and their associated
arrays of line break markers. MINSIZE is the minimum size of VISIBLE_LINE arrays of line break markers. MINSIZE is the minimum size of VISIBLE_LINE
and INVISIBLE_LINE; if it is greater than LINE_SIZE, LINE_SIZE is and INVISIBLE_LINE; if it is greater than LINE_SIZE, LINE_SIZE is
@@ -610,34 +654,12 @@ rl_expand_prompt (char *prompt)
static void static void
init_line_structures (int minsize) init_line_structures (int minsize)
{ {
register int n;
int osize;
osize = minsize;
if (minsize <= _rl_screenwidth) /* XXX - for gdb */
minsize = _rl_screenwidth + 1;
if (invisible_line == 0) /* initialize it */ if (invisible_line == 0) /* initialize it */
{ {
if (line_size < minsize) if (line_size > minsize)
line_size = minsize; minsize = line_size;
visible_line = (char *)xmalloc (line_size);
invisible_line = (char *)xmalloc (line_size);
}
else if (line_size < minsize) /* ensure it can hold MINSIZE chars */
{
line_size *= 2;
if (line_size < minsize)
line_size = minsize;
visible_line = (char *)xrealloc (visible_line, line_size);
invisible_line = (char *)xrealloc (invisible_line, line_size);
}
for (n = osize; n < line_size; n++)
{
visible_line[n] = 0;
invisible_line[n] = 1;
} }
realloc_line (minsize);
if (vis_lbreaks == 0) if (vis_lbreaks == 0)
{ {
@@ -660,6 +682,43 @@ init_line_structures (int minsize)
line_structures_initialized = 1; line_structures_initialized = 1;
} }
/* Convenience functions to add chars to the invisible line that update the
face information at the same time. */
static void /* XXX - change this */
invis_addc (int *outp, char c, char face)
{
realloc_line (*outp + 1);
invisible_line[*outp] = c;
inv_face[*outp] = face;
*outp += 1;
}
static void
invis_adds (int *outp, const char *str, int n, char face)
{
int i;
for (i = 0; i < n; i++)
invis_addc (outp, str[i], face);
}
static void
invis_nul (int *outp)
{
invis_addc (outp, '\0', 0);
*outp -= 1;
}
static void
set_active_region (int *beg, int *end)
{
if (rl_point >= 0 && rl_point <= rl_end && rl_mark >= 0 && rl_mark <= rl_end)
{
*beg = (rl_mark < rl_point) ? rl_mark : rl_point;
*end = (rl_mark < rl_point) ? rl_point : rl_mark;
}
}
/* Do whatever tests are necessary and tell update_line that it can do a /* Do whatever tests are necessary and tell update_line that it can do a
quick, dumb redisplay on the assumption that there are so many quick, dumb redisplay on the assumption that there are so many
differences between the old and new lines that it would be a waste to differences between the old and new lines that it would be a waste to
@@ -678,11 +737,12 @@ _rl_optimize_redisplay (void)
void void
rl_redisplay (void) rl_redisplay (void)
{ {
register int in, out, c, linenum, cursor_linenum; int in, out, c, linenum, cursor_linenum;
register char *line;
int inv_botlin, lb_botlin, lb_linenum, o_cpos; int inv_botlin, lb_botlin, lb_linenum, o_cpos;
int newlines, lpos, temp, n0, num, prompt_lines_estimate; int newlines, lpos, temp, n0, num, prompt_lines_estimate;
char *prompt_this_line; char *prompt_this_line;
char cur_face;
int hl_begin, hl_end;
int mb_cur_max = MB_CUR_MAX; int mb_cur_max = MB_CUR_MAX;
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
wchar_t wc; wchar_t wc;
@@ -700,6 +760,14 @@ rl_redisplay (void)
_rl_block_sigint (); _rl_block_sigint ();
RL_SETSTATE (RL_STATE_REDISPLAYING); RL_SETSTATE (RL_STATE_REDISPLAYING);
cur_face = FACE_NORMAL;
/* Can turn this into an array for multiple highlighted objects in addition
to the region */
hl_begin = hl_end = -1;
if (rl_mark_active_p ())
set_active_region (&hl_begin, &hl_end);
if (!rl_display_prompt) if (!rl_display_prompt)
rl_display_prompt = ""; rl_display_prompt = "";
@@ -728,7 +796,6 @@ rl_redisplay (void)
prompt_multibyte_chars = prompt_visible_length - prompt_physical_chars; prompt_multibyte_chars = prompt_visible_length - prompt_physical_chars;
line = invisible_line;
out = inv_botlin = 0; out = inv_botlin = 0;
/* Mark the line as modified or not. We only do this for history /* Mark the line as modified or not. We only do this for history
@@ -736,8 +803,8 @@ rl_redisplay (void)
modmark = 0; modmark = 0;
if (_rl_mark_modified_lines && current_history () && rl_undo_list) if (_rl_mark_modified_lines && current_history () && rl_undo_list)
{ {
line[out++] = '*'; invis_addc (&out, '*', cur_face);
line[out] = '\0'; invis_nul (&out);
modmark = 1; modmark = 1;
} }
@@ -762,17 +829,9 @@ rl_redisplay (void)
if (local_prompt_len > 0) if (local_prompt_len > 0)
{ {
temp = local_prompt_len + out + 2; invis_adds (&out, local_prompt, local_prompt_len, cur_face);
if (temp >= line_size) invis_nul (&out);
{
line_size = (temp + 1024) - (temp % 1024);
visible_line = (char *)xrealloc (visible_line, line_size);
line = invisible_line = (char *)xrealloc (invisible_line, line_size);
}
strncpy (line + out, local_prompt, local_prompt_len);
out += local_prompt_len;
} }
line[out] = '\0';
wrap_offset = local_prompt_len - prompt_visible_length; wrap_offset = local_prompt_len - prompt_visible_length;
} }
else else
@@ -796,16 +855,8 @@ rl_redisplay (void)
} }
prompt_physical_chars = pmtlen = strlen (prompt_this_line); /* XXX */ prompt_physical_chars = pmtlen = strlen (prompt_this_line); /* XXX */
temp = pmtlen + out + 2; invis_adds (&out, prompt_this_line, pmtlen, cur_face);
if (temp >= line_size) invis_nul (&out);
{
line_size = (temp + 1024) - (temp % 1024);
visible_line = (char *)xrealloc (visible_line, line_size);
line = invisible_line = (char *)xrealloc (invisible_line, line_size);
}
strncpy (line + out, prompt_this_line, pmtlen);
out += pmtlen;
line[out] = '\0';
wrap_offset = prompt_invis_chars_first_line = 0; wrap_offset = prompt_invis_chars_first_line = 0;
} }
@@ -967,14 +1018,6 @@ rl_redisplay (void)
} }
#endif #endif
if (out + 8 >= line_size) /* XXX - 8 for \t */
{
line_size *= 2;
visible_line = (char *)xrealloc (visible_line, line_size);
invisible_line = (char *)xrealloc (invisible_line, line_size);
line = invisible_line;
}
if (in == rl_point) if (in == rl_point)
{ {
cpos_buffer_position = out; cpos_buffer_position = out;
@@ -989,9 +1032,12 @@ rl_redisplay (void)
{ {
if (_rl_output_meta_chars == 0) if (_rl_output_meta_chars == 0)
{ {
sprintf (line + out, "\\%o", c); char obuf[5];
int olen;
if (lpos + 4 >= _rl_screenwidth) olen = sprintf (obuf, "\\%o", c);
if (lpos + olen >= _rl_screenwidth)
{ {
temp = _rl_screenwidth - lpos; temp = _rl_screenwidth - lpos;
CHECK_INV_LBREAKS (); CHECK_INV_LBREAKS ();
@@ -999,16 +1045,20 @@ rl_redisplay (void)
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn; line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn;
#endif #endif
lpos = 4 - temp; lpos = olen - temp;
} }
else else
lpos += 4; lpos += olen;
out += 4; for (temp = 0; temp < olen; temp++)
{
invis_addc (&out, obuf[temp], cur_face);
CHECK_LPOS ();
}
} }
else else
{ {
line[out++] = c; invis_addc (&out, c, cur_face);
CHECK_LPOS(); CHECK_LPOS();
} }
} }
@@ -1030,19 +1080,19 @@ rl_redisplay (void)
#endif #endif
lpos = temp - temp2; lpos = temp - temp2;
while (out < newout) while (out < newout)
line[out++] = ' '; invis_addc (&out, ' ', cur_face);
} }
else else
{ {
while (out < newout) while (out < newout)
line[out++] = ' '; invis_addc (&out, ' ', cur_face);
lpos += temp; lpos += temp;
} }
} }
#endif #endif
else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up) else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
{ {
line[out++] = '\0'; /* XXX - sentinel */ invis_addc (&out, '\0', cur_face);
CHECK_INV_LBREAKS (); CHECK_INV_LBREAKS ();
inv_lbreaks[++newlines] = out; inv_lbreaks[++newlines] = out;
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
@@ -1052,9 +1102,9 @@ rl_redisplay (void)
} }
else if (CTRL_CHAR (c) || c == RUBOUT) else if (CTRL_CHAR (c) || c == RUBOUT)
{ {
line[out++] = '^'; invis_addc (&out, '^', cur_face);
CHECK_LPOS(); CHECK_LPOS();
line[out++] = CTRL_CHAR (c) ? UNCTRL (c) : '?'; invis_addc (&out, CTRL_CHAR (c) ? UNCTRL (c) : '?', cur_face);
CHECK_LPOS(); CHECK_LPOS();
} }
else else
@@ -1070,7 +1120,7 @@ rl_redisplay (void)
for (i = lpos; i < _rl_screenwidth; i++) for (i = lpos; i < _rl_screenwidth; i++)
{ {
/* The space will be removed in update_line() */ /* The space will be removed in update_line() */
line[out++] = ' '; invis_addc (&out, ' ', cur_face);
_rl_wrapped_multicolumn++; _rl_wrapped_multicolumn++;
CHECK_LPOS(); CHECK_LPOS();
} }
@@ -1080,17 +1130,17 @@ rl_redisplay (void)
lb_linenum = newlines; lb_linenum = newlines;
} }
for (i = in; i < in+wc_bytes; i++) for (i = in; i < in+wc_bytes; i++)
line[out++] = rl_line_buffer[i]; invis_addc (&out, rl_line_buffer[i], cur_face);
for (i = 0; i < wc_width; i++) for (i = 0; i < wc_width; i++)
CHECK_LPOS(); CHECK_LPOS();
} }
else else
{ {
line[out++] = c; invis_addc (&out, c, cur_face);
CHECK_LPOS(); CHECK_LPOS();
} }
#else #else
line[out++] = c; invis_addc (&out, c, cur_face);
CHECK_LPOS(); CHECK_LPOS();
#endif #endif
} }
@@ -1112,7 +1162,7 @@ rl_redisplay (void)
in++; in++;
#endif #endif
} }
line[out] = '\0'; invis_nul (&out);
line_totbytes = out; line_totbytes = out;
if (cpos_buffer_position < 0) if (cpos_buffer_position < 0)
{ {
@@ -1161,7 +1211,7 @@ rl_redisplay (void)
{ {
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
if (mb_cur_max > 1 && rl_byte_oriented == 0) if (mb_cur_max > 1 && rl_byte_oriented == 0)
out = _rl_find_prev_mbchar (line, _rl_screenchars, MB_FIND_ANY); out = _rl_find_prev_mbchar (invisible_line, _rl_screenchars, MB_FIND_ANY);
else else
#endif #endif
out = _rl_screenchars - 1; out = _rl_screenchars - 1;
@@ -1179,8 +1229,11 @@ rl_redisplay (void)
#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l])) #define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
#define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l]) #define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l])
#define VIS_CHARS(line) (visible_line + vis_lbreaks[line]) #define VIS_CHARS(line) (visible_line + vis_lbreaks[line])
#define VIS_FACE(line) (visible_face + vis_lbreaks[line]);
#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line) #define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)
#define VIS_LINE_FACE(line) ((line) > _rl_vis_botlin) ? "" : VIS_FACE(line)
#define INV_LINE(line) (invisible_line + inv_lbreaks[line]) #define INV_LINE(line) (invisible_line + inv_lbreaks[line])
#define INV_LINE_FACE(line) (invisible_face + inv_lbreaks[line])
#define OLD_CPOS_IN_PROMPT() (cpos_adjusted == 0 && \ #define OLD_CPOS_IN_PROMPT() (cpos_adjusted == 0 && \
_rl_last_c_pos != o_cpos && \ _rl_last_c_pos != o_cpos && \
@@ -1427,7 +1480,7 @@ rl_redisplay (void)
/* If the first character on the screen isn't the first character /* If the first character on the screen isn't the first character
in the display line, indicate this with a special character. */ in the display line, indicate this with a special character. */
if (lmargin > 0) if (lmargin > 0)
line[lmargin] = '<'; invisible_line[lmargin] = '<';
/* If SCREENWIDTH characters starting at LMARGIN do not encompass /* If SCREENWIDTH characters starting at LMARGIN do not encompass
the whole line, indicate that with a special character at the the whole line, indicate that with a special character at the
@@ -1435,7 +1488,7 @@ rl_redisplay (void)
wrap offset into account. */ wrap offset into account. */
t = lmargin + M_OFFSET (lmargin, wrap_offset) + _rl_screenwidth; t = lmargin + M_OFFSET (lmargin, wrap_offset) + _rl_screenwidth;
if (t > 0 && t < out) if (t > 0 && t < out)
line[t - 1] = '>'; invisible_line[t - 1] = '>';
if (rl_display_fixed == 0 || forced_display || lmargin != last_lmargin) if (rl_display_fixed == 0 || forced_display || lmargin != last_lmargin)
{ {
@@ -2524,7 +2577,7 @@ rl_redraw_prompt_last_line (void)
DATA is the contents of the screen line of interest; i.e., where DATA is the contents of the screen line of interest; i.e., where
the movement is being done. the movement is being done.
DATA is always the visible line or the invisible line */ DATA is always the visible line or the invisible line */
void static void
_rl_move_cursor_relative (int new, const char *data) _rl_move_cursor_relative (int new, const char *data)
{ {
register int i; register int i;
@@ -3281,6 +3334,14 @@ _rl_current_display_line (void)
return ret; return ret;
} }
void
_rl_refresh_line (void)
{
rl_clear_visible_line ();
rl_redraw_prompt_last_line ();
rl_keep_mark_active ();
}
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
/* Calculate the number of screen columns occupied by STR from START to END. /* Calculate the number of screen columns occupied by STR from START to END.
In the case of multibyte characters with stateful encoding, we have to In the case of multibyte characters with stateful encoding, we have to
+4 -2
View File
@@ -1,7 +1,7 @@
/* rlprivate.h -- functions and variables global to the readline library, /* rlprivate.h -- functions and variables global to the readline library,
but not intended for use by applications. */ but not intended for use by applications. */
/* Copyright (C) 1999-2019 Free Software Foundation, Inc. /* Copyright (C) 1999-2020 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@@ -267,7 +267,6 @@ extern void _rl_free_match_list PARAMS((char **));
/* display.c */ /* display.c */
extern char *_rl_strip_prompt PARAMS((char *)); extern char *_rl_strip_prompt PARAMS((char *));
extern void _rl_reset_prompt PARAMS((void)); extern void _rl_reset_prompt PARAMS((void));
extern void _rl_move_cursor_relative PARAMS((int, const char *));
extern void _rl_move_vert PARAMS((int)); extern void _rl_move_vert PARAMS((int));
extern void _rl_save_prompt PARAMS((void)); extern void _rl_save_prompt PARAMS((void));
extern void _rl_restore_prompt PARAMS((void)); extern void _rl_restore_prompt PARAMS((void));
@@ -281,6 +280,7 @@ extern void _rl_redisplay_after_sigwinch PARAMS((void));
extern void _rl_clean_up_for_exit PARAMS((void)); extern void _rl_clean_up_for_exit PARAMS((void));
extern void _rl_erase_entire_line PARAMS((void)); extern void _rl_erase_entire_line PARAMS((void));
extern int _rl_current_display_line PARAMS((void)); extern int _rl_current_display_line PARAMS((void));
extern void _rl_refresh_line PARAMS((void));
/* input.c */ /* input.c */
extern int _rl_any_typein PARAMS((void)); extern int _rl_any_typein PARAMS((void));
@@ -385,6 +385,8 @@ extern void _rl_enable_meta_key PARAMS((void));
extern void _rl_disable_meta_key PARAMS((void)); extern void _rl_disable_meta_key PARAMS((void));
extern void _rl_control_keypad PARAMS((int)); extern void _rl_control_keypad PARAMS((int));
extern void _rl_set_cursor PARAMS((int, int)); extern void _rl_set_cursor PARAMS((int, int));
extern void _rl_standout_on PARAMS((void));
extern void _rl_standout_off PARAMS((void));
/* text.c */ /* text.c */
extern void _rl_fix_point PARAMS((int)); extern void _rl_fix_point PARAMS((int));
+24
View File
@@ -739,6 +739,30 @@ rl_ding (void)
return (-1); return (-1);
} }
/* **************************************************************** */
/* */
/* Entering and leaving terminal standout mode */
/* */
/* **************************************************************** */
void
_rl_standout_on (void)
{
#ifndef __MSDOS__
if (_rl_term_so && _rl_term_se)
tputs (_rl_term_so, 1, _rl_output_character_function);
#endif
}
void
_rl_standout_off (void)
{
#ifndef __MSDOS__
if (_rl_term_so && _rl_term_se)
tputs (_rl_term_se, 1, _rl_output_character_function);
#endif
}
/* **************************************************************** */ /* **************************************************************** */
/* */ /* */
/* Controlling the Meta Key and Keypad */ /* Controlling the Meta Key and Keypad */
+1 -11
View File
@@ -580,18 +580,8 @@ rl_backward_word (int count, int key)
int int
rl_refresh_line (int ignore1, int ignore2) rl_refresh_line (int ignore1, int ignore2)
{ {
int curr_line; _rl_refresh_line ();
curr_line = _rl_current_display_line ();
_rl_move_vert (curr_line);
_rl_move_cursor_relative (0, rl_line_buffer); /* XXX is this right */
_rl_clear_to_eol (0); /* arg of 0 means to not use spaces */
rl_redraw_prompt_last_line ();
rl_display_fixed = 1; rl_display_fixed = 1;
return 0; return 0;
} }
+11 -6
View File
@@ -55,12 +55,17 @@ zread (fd, buf, len)
check_signals (); /* check for signals before a blocking read */ check_signals (); /* check for signals before a blocking read */
while ((r = read (fd, buf, len)) < 0 && errno == EINTR) while ((r = read (fd, buf, len)) < 0 && errno == EINTR)
/* XXX - bash-5.0 */ {
/* We check executing_builtin and run traps here for backwards compatibility */ int t;
if (executing_builtin) t = errno;
check_signals_and_traps (); /* XXX - should it be check_signals()? */ /* XXX - bash-5.0 */
else /* We check executing_builtin and run traps here for backwards compatibility */
check_signals (); if (executing_builtin)
check_signals_and_traps (); /* XXX - should it be check_signals()? */
else
check_signals ();
errno = t;
}
return r; return r;
} }
+346 -694
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -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 THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR PATH=$PATH:$BUILD_DIR
+4 -3
View File
@@ -121,6 +121,9 @@ int wait_signal_received;
int trapped_signal_received; int trapped_signal_received;
/* Set to 1 to suppress the effect of `set v' in the DEBUG trap. */
int suppress_debug_trap_verbose = 0;
#define GETORIGSIG(sig) \ #define GETORIGSIG(sig) \
do { \ do { \
original_signals[sig] = (SigHandler *)set_signal_handler (sig, SIG_DFL); \ original_signals[sig] = (SigHandler *)set_signal_handler (sig, SIG_DFL); \
@@ -1137,9 +1140,7 @@ run_debug_trap ()
#endif #endif
old_verbose = echo_input_at_read; old_verbose = echo_input_at_read;
#if 0 /* not yet */ echo_input_at_read = suppress_debug_trap_verbose ? 0 : echo_input_at_read;
echo_input_at_read = 0;
#endif
trap_exit_value = _run_trap_internal (DEBUG_TRAP, "debug trap"); trap_exit_value = _run_trap_internal (DEBUG_TRAP, "debug trap");
+1
View File
@@ -64,6 +64,7 @@ extern int trapped_signal_received;
extern int wait_signal_received; extern int wait_signal_received;
extern int running_trap; extern int running_trap;
extern int trap_saved_exit_value; extern int trap_saved_exit_value;
extern int suppress_debug_trap_verbose;
/* Externally-visible functions declared in trap.c. */ /* Externally-visible functions declared in trap.c. */
extern void initialize_traps PARAMS((void)); extern void initialize_traps PARAMS((void));
+27 -4
View File
@@ -1,6 +1,6 @@
/* variables.c -- Functions for hacking shell variables. */ /* variables.c -- Functions for hacking shell variables. */
/* Copyright (C) 1987-2019 Free Software Foundation, Inc. /* Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell. This file is part of GNU Bash, the Bourne Again SHell.
@@ -94,6 +94,7 @@
#define FV_FORCETEMPENV 0x01 #define FV_FORCETEMPENV 0x01
#define FV_SKIPINVISIBLE 0x02 #define FV_SKIPINVISIBLE 0x02
#define FV_NODYNAMIC 0x04
extern char **environ; extern char **environ;
@@ -1297,8 +1298,14 @@ assign_seconds (self, value, unused, key)
char *key; char *key;
{ {
struct timeval tv; struct timeval tv;
if (legal_number (value, &seconds_value_assigned) == 0) intmax_t nval;
seconds_value_assigned = 0; int expok;
if (integer_p (self))
nval = evalexp (value, 0, &expok);
else
expok = legal_number (value, &nval);
seconds_value_assigned = expok ? nval : 0;
gettimeofday (&tv, NULL); gettimeofday (&tv, NULL);
shell_start_time = tv.tv_sec; shell_start_time = tv.tv_sec;
return (self); return (self);
@@ -1503,7 +1510,16 @@ assign_random (self, value, unused, key)
arrayind_t unused; arrayind_t unused;
char *key; char *key;
{ {
sbrand (strtoul (value, (char **)NULL, 10)); intmax_t seedval;
int expok;
if (integer_p (self))
seedval = evalexp (value, 0, &expok);
else
expok = legal_number (value, &seedval);
if (expok == 0)
return (self);
sbrand (seedval);
if (subshell_environment) if (subshell_environment)
seeded_subshell = getpid (); seeded_subshell = getpid ();
return (self); return (self);
@@ -3280,6 +3296,13 @@ bind_variable_internal (name, value, table, hflags, aflags)
} }
else if (entry->assign_func) /* array vars have assign functions now */ else if (entry->assign_func) /* array vars have assign functions now */
{ {
if ((readonly_p (entry) && (aflags & ASS_FORCE) == 0) || noassign_p (entry))
{
if (readonly_p (entry))
err_readonly (name_cell (entry));
return (entry);
}
INVALIDATE_EXPORTSTR (entry); INVALIDATE_EXPORTSTR (entry);
newval = (aflags & ASS_APPEND) ? make_variable_value (entry, value, aflags) : value; newval = (aflags & ASS_APPEND) ? make_variable_value (entry, value, aflags) : value;
if (assoc_p (entry)) if (assoc_p (entry))