summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2022-03-11 16:09:24 -0500
committerChet Ramey <chet.ramey@case.edu>2022-03-11 16:09:24 -0500
commitb6a567e7f13406952cbb1d1adb2f00b2260a871e (patch)
treeaae41d433ff68ad0fb17ba8e5d39987adb4be684
parentb4e5e5505cc4495c6237c32a65ba62ebcc497b31 (diff)
downloadbash-b6a567e7f13406952cbb1d1adb2f00b2260a871e.tar.gz
fix problem with saving tty state after running a command with 'bind -x'; builtins that create associative arrays can now convert existing scalar variables to associative arrays
-rw-r--r--CWRU/CWRU.chlog18
-rw-r--r--arrayfunc.c2
-rw-r--r--doc/bash.122
-rw-r--r--doc/bashref.texi3
-rw-r--r--examples/loadables/csv.c14
-rw-r--r--examples/loadables/stat.c22
-rw-r--r--jobs.c4
-rw-r--r--lib/readline/doc/readline.316
-rw-r--r--lib/readline/doc/rluser.texi13
-rw-r--r--lib/readline/doc/version.texi6
10 files changed, 77 insertions, 43 deletions
diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog
index ef39921..f86f0cb 100644
--- a/CWRU/CWRU.chlog
+++ b/CWRU/CWRU.chlog
@@ -3341,3 +3341,21 @@ parse.y
`make visible' flag or through sh_strvis if we're not running the
prompt string through word expansions. Fixes issue reported by
Josh Harcome <joshharc@gmail.com> back in mid-January
+
+ 3/10
+ ----
+arrayfunc.c
+ - convert_var_to_array: if we're being asked to create an associative
+ array (flags & 2), and we have an existing variable that is not an
+ assoc array (and not an existing indexed array), call
+ convert_var_to_assoc to make it one
+
+ 3/11
+ ----
+jobs.c
+ - wait_for: don't call get_tty_state() if readline is dispatching
+ (RL_STATE_DISPATCHING) with the terminal settings changed
+ (RL_STATE_TERMPREPPED), the same way we don't if we are running a
+ command for programmable completion. Fixes bug with SIGINT reverting
+ to the saved readline terminal settings reported by
+ Markus Napierkowski <markus.napierkowski@cyberus-technology.de>
diff --git a/arrayfunc.c b/arrayfunc.c
index 303a4a5..2ab172c 100644
--- a/arrayfunc.c
+++ b/arrayfunc.c
@@ -504,6 +504,8 @@ find_or_make_array_variable (name, flags)
report_error (_("%s: cannot convert indexed to associative array"), name);
return ((SHELL_VAR *)NULL);
}
+ else if (flags & 2)
+ var = assoc_p (var) ? var : convert_var_to_assoc (var);
else if (array_p (var) == 0 && assoc_p (var) == 0)
var = convert_var_to_array (var);
diff --git a/doc/bash.1 b/doc/bash.1
index d5d0e27..d37bed8 100644
--- a/doc/bash.1
+++ b/doc/bash.1
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
-.\" Last Change: Thu Feb 24 14:43:14 EST 2022
+.\" Last Change: Fri Mar 11 10:16:50 EST 2022
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
-.TH BASH 1 "2022 February 24" "GNU Bash 5.2"
+.TH BASH 1 "2022 March 11" "GNU Bash 5.2"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -2774,6 +2774,12 @@ interpreted as relative to one greater than the maximum index of
\fIname\fP, so negative indices count back from the end of the
array, and an index of \-1 references the last element.
.PP
+The += operator will append to a array variable when assigning
+using the compound assignment syntax; see
+.SM
+.B PARAMETERS
+above.
+.PP
Any element of an array may be referenced using
${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid
conflicts with pathname expansion. If
@@ -6081,13 +6087,11 @@ The active region shows the text inserted by bracketed-paste and any
matching text found by incremental and non-incremental history searches.
.TP
.B enable\-bracketed\-paste (On)
-When set to \fBOn\fP, readline will configure the terminal in a way
-that will enable it to insert each paste into the editing buffer as a
-single string of characters, instead of treating each character as if
-it had been read from the keyboard
-and executing any editing commands
-bound to key sequences appearing in the pasted text.
-This will prevent pasted characters from being interpreted as editing commands.
+When set to \fBOn\fP, readline configures the terminal to insert each
+paste into the editing buffer as a single string of characters, instead
+of treating each character as if it had been read from the keyboard.
+This prevents readline from executing any editing commands bound to key
+sequences appearing in the pasted text.
.TP
.B enable\-keypad (Off)
When set to \fBOn\fP, readline will try to enable the application
diff --git a/doc/bashref.texi b/doc/bashref.texi
index 94f97ab..f0f95c0 100644
--- a/doc/bashref.texi
+++ b/doc/bashref.texi
@@ -7701,6 +7701,9 @@ interpreted as relative to one greater than the maximum index of
@var{name}, so negative indices count back from the end of the
array, and an index of -1 references the last element.
+The @samp{+=} operator will append to a array variable when assigning
+using the compound assignment syntax; see @ref{Shell Parameters} above.
+
Any element of an array may be referenced using
@code{$@{@var{name}[@var{subscript}]@}}.
The braces are required to avoid
diff --git a/examples/loadables/csv.c b/examples/loadables/csv.c
index 11228f1..75b3772 100644
--- a/examples/loadables/csv.c
+++ b/examples/loadables/csv.c
@@ -39,9 +39,9 @@
element of array variable CSV, starting at index 0. The format of LINE is
as described in RFC 4180. */
static int
-csvsplit (csv, line)
+csvsplit (csv, line, dstring)
SHELL_VAR *csv;
- char *line;
+ char *line, *dstring;
{
arrayind_t ind;
char *field, *prev, *buf, *xbuf;
@@ -67,7 +67,7 @@ csvsplit (csv, line)
buf[b++] = *field++; /* skip double quote */
else if (qstate == DQUOTE && *field == '"')
qstate = NQUOTE;
- else if (qstate == NQUOTE && *field == ',')
+ else if (qstate == NQUOTE && *field == *dstring)
break;
else
/* This copies any text between a closing double quote and the
@@ -80,7 +80,7 @@ csvsplit (csv, line)
else
{
buf = prev;
- field = prev + strcspn (prev, ",");
+ field = prev + strcspn (prev, dstring);
}
delim = *field;
@@ -91,10 +91,10 @@ csvsplit (csv, line)
*field = delim;
- if (delim == ',')
+ if (delim == *dstring)
prev = field + 1;
}
- while (delim == ',');
+ while (delim == *dstring);
if (xbuf)
free (xbuf);
@@ -165,7 +165,7 @@ csv_builtin (list)
if (csvstring == 0 || *csvstring == 0)
return (EXECUTION_SUCCESS);
- opt = csvsplit (v, csvstring);
+ opt = csvsplit (v, csvstring, ",");
/* Maybe do something with OPT here, it's the number of fields */
return (rval);
diff --git a/examples/loadables/stat.c b/examples/loadables/stat.c
index 3725a9c..1e60e7b 100644
--- a/examples/loadables/stat.c
+++ b/examples/loadables/stat.c
@@ -3,7 +3,7 @@
/* See Makefile for compilation details. */
/*
- Copyright (C) 2016 Free Software Foundation, Inc.
+ Copyright (C) 2016,2022 Free Software Foundation, Inc.
This file is part of GNU Bash.
Bash is free software: you can redistribute it and/or modify
@@ -390,6 +390,12 @@ stat_builtin (list)
}
}
+ if (legal_identifier (aname) == 0)
+ {
+ sh_invalidid (aname);
+ return (EXECUTION_FAILURE);
+ }
+
list = loptend;
if (list == 0)
{
@@ -397,6 +403,10 @@ stat_builtin (list)
return (EX_USAGE);
}
+
+#if 0
+ unbind_variable (aname);
+#endif
fname = list->word->word;
if (getstat (fname, flags, &st) < 0)
@@ -405,8 +415,7 @@ stat_builtin (list)
return (EXECUTION_FAILURE);
}
- unbind_variable (aname);
- v = make_new_assoc_variable (aname);
+ v = find_or_make_array_variable (aname, 3);
if (v == 0)
{
builtin_error ("%s: cannot create variable", aname);
@@ -430,9 +439,10 @@ char *stat_doc[] = {
"",
"Take a filename and load the status information returned by a",
"stat(2) call on that file into the associative array specified",
- "by the -A option. The default array name is STAT. If the -L",
- "option is supplied, stat does not resolve symbolic links and",
- "reports information about the link itself. The -l option results",
+ "by the -A option. The default array name is STAT.",
+ "",
+ "If the -L option is supplied, stat does not resolve symbolic links",
+ "and reports information about the link itself. The -l option results",
"in longer-form listings for some of the fields. When -l is used,",
"the -F option supplies a format string passed to strftime(3) to",
"display the file time information.",
diff --git a/jobs.c b/jobs.c
index 25289f4..77d9dc3 100644
--- a/jobs.c
+++ b/jobs.c
@@ -3117,8 +3117,8 @@ if (job == NO_JOB)
else
#if defined (READLINE)
/* We don't want to do this if we are running a process during
- programmable completion. */
- if (RL_ISSTATE (RL_STATE_COMPLETING) == 0)
+ programmable completion or a command bound to `bind -x'. */
+ if (RL_ISSTATE (RL_STATE_COMPLETING|RL_STATE_DISPATCHING|RL_STATE_TERMPREPPED) == 0)
#endif
get_tty_state ();
diff --git a/lib/readline/doc/readline.3 b/lib/readline/doc/readline.3
index b61d542..912718d 100644
--- a/lib/readline/doc/readline.3
+++ b/lib/readline/doc/readline.3
@@ -6,9 +6,9 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
-.\" Last Change: Thu Feb 10 10:58:32 EST 2022
+.\" Last Change: Fri Mar 11 10:14:10 EST 2022
.\"
-.TH READLINE 3 "2022 February 10" "GNU Readline 8.2"
+.TH READLINE 3 "2022 March 11" "GNU Readline 8.2"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
@@ -489,13 +489,11 @@ The active region shows the text inserted by bracketed-paste and any
matching text found by incremental and non-incremental history searches.
.TP
.B enable\-bracketed\-paste (On)
-When set to \fBOn\fP, readline will configure the terminal in a way
-that will enable it to insert each paste into the editing buffer as a
-single string of characters, instead of treating each character as if
-it had been read from the keyboard
-and executing any editing commands
-bound to key sequences appearing in the pasted text.
-This will prevent pasted characters from being interpreted as editing commands.
+When set to \fBOn\fP, readline configures the terminal to insert each
+paste into the editing buffer as a single string of characters, instead
+of treating each character as if it had been read from the keyboard.
+This prevents readline from executing any editing commands bound to key
+sequences appearing in the pasted text.
.TP
.B enable\-keypad (Off)
When set to \fBOn\fP, readline will try to enable the application
diff --git a/lib/readline/doc/rluser.texi b/lib/readline/doc/rluser.texi
index deaff14..0921d24 100644
--- a/lib/readline/doc/rluser.texi
+++ b/lib/readline/doc/rluser.texi
@@ -588,13 +588,12 @@ The default is @samp{On}.
@item enable-bracketed-paste
@vindex enable-bracketed-paste
-When set to @samp{On}, Readline will configure the terminal in a way
-that will enable it to insert each paste into the editing buffer as a
-single string of characters, instead of treating each character as if
-it had been read from the keyboard
-and executing any editing commands
-bound to key sequences appearing in the pasted text.
-This will prevent pasted characters from being interpreted as editing commands.
+When set to @samp{On}, Readline configures the terminal to insert each
+paste into the editing buffer as a single string of characters, instead
+of treating each character as if it had been read from the keyboard.
+This is called putting the terminal into @dfn{bracketed paste mode};
+it prevents Readline from executing any editing commands bound to key
+sequences appearing in the pasted text.
The default is @samp{On}.
@item enable-keypad
diff --git a/lib/readline/doc/version.texi b/lib/readline/doc/version.texi
index 42ead15..cd3f8d8 100644
--- a/lib/readline/doc/version.texi
+++ b/lib/readline/doc/version.texi
@@ -5,7 +5,7 @@ Copyright (C) 1988-2022 Free Software Foundation, Inc.
@set EDITION 8.2
@set VERSION 8.2
-@set UPDATED 18 February 2022
-@set UPDATED-MONTH February 2022
+@set UPDATED 11 March 2022
+@set UPDATED-MONTH March 2022
-@set LASTCHANGE Fri Feb 18 11:12:48 EST 2022
+@set LASTCHANGE Fri Mar 11 10:13:51 EST 2022