allow quoted-insert while reading readline search strings; force filename argument to enable -f without a slash to read from the current directory; update BASH_LOADABLES_PATH documentation

This commit is contained in:
Chet Ramey
2023-11-14 10:20:05 -05:00
parent 511fef0f5c
commit f491b93350
13 changed files with 118 additions and 21 deletions
+22
View File
@@ -7973,3 +7973,25 @@ lib/readline/emacs_keymap.c
lib/readline/doc/rluser.texi
- execute-named-command: document as bindable function name with its
default binding to M-x in emacs mode
11/6
----
lib/readline/search.c
- _rl_nsearch_dispatch: use ^V/^Q for rl_quoted_insert into the
search string
lib/readline/isearch.c
- _rl_isearch_dispatch: use ^V or anything bound to rl_quoted_insert
for rl_quoted_insert into the search string
lib/readline/terminal.c
- add support for new BE/BD and PS/PE bracketed-paste capabilities.
Nothing uses them yet.
11/10
-----
builtins/enable.def
- dyn_load_builtin: if we don't find a pathname argument without a
slash in BASH_LOADABLES_PATH, convert it to a pathname with a slash
before calling dlopen, to force the loader to look in the current
directory (Linux, for example, will not).
+14 -2
View File
@@ -41,6 +41,11 @@ Options controlling dynamic loading:
Without options, each NAME is enabled.
On systems with dynamic loading, the shell variable BASH_LOADABLES_PATH
defines a search path for the directory containing FILENAMEs that do
not contain a slash. It may include "." to force a search of the current
directory.
To use the `test' found in $PATH instead of the shell builtin
version, type `enable -n test'.
@@ -363,11 +368,18 @@ dyn_load_builtin (WORD_LIST *list, int flags, char *filename)
/* Fall back to current directory for now */
if (handle == 0)
{
char *openname;
openname = absolute_program (filename) ? filename : make_absolute (filename, ".");
#if defined (_AIX)
handle = dlopen (filename, RTLD_NOW|RTLD_GLOBAL);
handle = dlopen (openname, RTLD_NOW|RTLD_GLOBAL);
#else
handle = dlopen (filename, RTLD_LAZY);
handle = dlopen (openname, RTLD_LAZY);
#endif /* !_AIX */
if (openname != filename)
free (openname);
}
if (handle == 0)
{
+3 -2
View File
@@ -172,8 +172,9 @@ char *localvar_builtins[] =
/* The builtin commands that are special to the POSIX search order. */
char *posix_builtins[] =
{
"alias", "bg", "cd", "command", "false", "fc", "fg", "getopts", "jobs",
"kill", "newgrp", "pwd", "read", "true", "umask", "unalias", "wait",
"alias", "bg", "cd", "command", "false", "fc", "fg", "getopts", "hash",
"jobs", "kill", "newgrp", "pwd", "read", "true", "type", "ulimit",
"umask", "unalias", "wait",
(char *)NULL
};
+10 -9
View File
@@ -5,14 +5,14 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Wed Nov 1 09:34:21 EDT 2023
.\" Last Change: Mon Nov 6 10:19:40 EST 2023
.\"
.\" bash_builtins, strip all but Built-Ins section
.\" avoid a warning about an undefined register
.\" .if !rzY .nr zY 0
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2023 November 1" "GNU Bash 5.3"
.TH BASH 1 "2023 November 6" "GNU Bash 5.3"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -8839,8 +8839,10 @@ from shared object
.IR filename ,
on systems that support dynamic loading.
\fBBash\fP will use the value of the \fBBASH_LOADABLES_PATH\fP variable as a
colon-separated list of directories in which to search for \fIfilename\fP.
The default is system-dependent.
colon-separated list of directories in which to search for \fIfilename\fP,
if \fIfilename\fP does not contain a slash.
The default is system-dependent,
and may include "." to force a search of the current directory.
The
.B \-d
option will delete a builtin previously loaded with
@@ -10896,14 +10898,13 @@ instead of double quotes.
If the string is not translated, this has no effect.
.TP 8
.B nullglob
If set,
.B bash
allows patterns which match no
files (see
If set, pathname expansion patterns which match no files
(see
.B Pathname Expansion
.ie \n(zZ=1 in \fIbash(1)\fP)
.el above)
to expand to a null string, rather than themselves.
expand to nothing and are removed,
rather than expanding to themselves.
.TP 8
.B patsub_replacement
If set, \fBbash\fP
+8 -4
View File
@@ -4852,8 +4852,10 @@ each builtin with an indication of whether or not it is enabled.
The @option{-f} option means to load the new builtin command @var{name}
from shared object @var{filename}, on systems that support dynamic loading.
Bash will use the value of the @env{BASH_LOADABLES_PATH} variable as a
colon-separated list of directories in which to search for @var{filename}.
The default is system-dependent.
colon-separated list of directories in which to search for @var{filename},
if @var{filename} does not contain a slash.
The default is system-dependent,
and may include "." to force a search of the current directory.
The @option{-d} option will delete a builtin loaded with @option{-f}.
If there are no options, a list of the shell builtins is displayed.
@@ -6048,8 +6050,10 @@ instead of double quotes.
If the string is not translated, this has no effect.
@item nullglob
If set, Bash allows filename patterns which match no
files to expand to a null string, rather than themselves.
If set, filename expansion patterns which match no files
(@pxref{Filename Expansion})
expand to nothing and are removed,
rather than expanding to themselves.
@item patsub_replacement
If set, Bash
+2 -2
View File
@@ -2,10 +2,10 @@
Copyright (C) 1988-2023 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Wed Nov 1 09:34:00 EDT 2023
@set LASTCHANGE Mon Nov 6 10:19:14 EST 2023
@set EDITION 5.3
@set VERSION 5.3
@set UPDATED 1 November 2023
@set UPDATED 6 November 2023
@set UPDATED-MONTH November 2023
+1 -1
View File
@@ -129,7 +129,7 @@ csv_builtin (WORD_LIST *list)
if (array_name == 0)
array_name = CSV_ARRAY_DEFAULT;
if (legal_identifier (array_name) == 0)
if (valid_identifier (array_name) == 0)
{
sh_invalidid (array_name);
return (EXECUTION_FAILURE);
+5
View File
@@ -559,6 +559,11 @@ extern void zsyncfd (int);
/* declarations for functions defined in lib/sh/zwrite.c */
extern int zwrite (int, char *, size_t);
/* compatibility functions for existing loadable builtins, from compat.c */
extern int legal_number (const char *, intmax_t *);
extern int legal_identifier (const char *);
extern int legal_alias_name (const char *, int);
/* declarations for functions defined in lib/glob/gmisc.c */
extern int match_pattern_char (char *, char *, int);
extern int umatchlen (char *, size_t);
+23
View File
@@ -447,6 +447,8 @@ add_character:
cxt->lastc = -6;
else if (f == rl_bracketed_paste_begin)
cxt->lastc = -7;
else if (c == CTRL('V') || f == rl_quoted_insert)
cxt->lastc = -8;
}
/* If we changed the keymap earlier while translating a key sequence into
@@ -712,6 +714,27 @@ opcode_dispatch:
xfree (paste);
break;
case -8: /* quoted insert */
#if defined (HANDLE_SIGNALS)
if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
_rl_disable_tty_signals ();
#endif
c = _rl_search_getchar (cxt);
#if defined (HANDLE_SIGNALS)
if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
_rl_restore_tty_signals ();
#endif
if (c < 0)
{
cxt->sflags |= SF_FAILED;
cxt->history_pos = cxt->last_found_line;
return -1;
}
_rl_add_executing_keyseq (c);
/*FALLTHROUGH*/
/* Add character to search string and continue search. */
default:
#if defined (HANDLE_MULTIBYTE)
+11
View File
@@ -341,6 +341,17 @@ _rl_nsearch_dispatch (_rl_search_cxt *cxt, int c)
rl_unix_line_discard (1, c);
break;
case CTRL('Q'):
case CTRL('V'):
n = rl_quoted_insert (1, c);
if (n < 0)
{
_rl_nsearch_abort (cxt);
return -1;
}
cxt->lastc = (rl_point > 0) ? rl_line_buffer[rl_point - 1] : rl_line_buffer[0];
break;
case RETURN:
case NEWLINE:
return 0;
+12
View File
@@ -185,6 +185,12 @@ static char *_rl_term_kN;
static char *_rl_term_vs; /* very visible */
static char *_rl_term_ve; /* normal */
/* Bracketed paste */
static char *_rl_term_BE; /* enable */
static char *_rl_term_BD; /* disable */
static char *_rl_term_PS; /* paste start */
static char *_rl_term_PE; /* paste end */
/* User-settable color sequences to begin and end the active region. Defaults
are rl_term_so and rl_term_se on non-dumb terminals. */
char *_rl_active_region_start_color = NULL;
@@ -415,9 +421,13 @@ struct _tc_string {
static const struct _tc_string tc_strings[] =
{
{ "@7", &_rl_term_at7 },
{ "BD", &_rl_term_BD },
{ "BE", &_rl_term_BE },
{ "DC", &_rl_term_DC },
{ "E3", &_rl_term_clrscroll },
{ "IC", &_rl_term_IC },
{ "PE", &_rl_term_PE },
{ "PS", &_rl_term_PS },
{ "ce", &_rl_term_clreol },
{ "cl", &_rl_term_clrpag },
{ "cr", &_rl_term_cr },
@@ -497,6 +507,7 @@ _rl_init_terminal_io (const char *terminal_name)
_rl_term_kh = _rl_term_kH = _rl_term_at7 = _rl_term_kI = (char *)NULL;
_rl_term_kN = _rl_term_kP = (char *)NULL;
_rl_term_so = _rl_term_se = (char *)NULL;
_rl_term_BD = _rl_term_BE = _rl_term_PE = _rl_term_PS = (char *)NULL;
#if defined(HACK_TERMCAP_MOTION)
_rl_term_forward_char = (char *)NULL;
#endif
@@ -567,6 +578,7 @@ _rl_init_terminal_io (const char *terminal_name)
/* Assume generic unknown terminal can't handle the enable/disable
escape sequences */
_rl_term_BD = _rl_term_BE = _rl_term_PE = _rl_term_PS = (char *)NULL;
_rl_enable_bracketed_paste = 0;
/* No terminal so/se capabilities. */
+1 -1
View File
@@ -2089,7 +2089,7 @@ _rl_readstr_dispatch (_rl_readstr_cxt *cxt, int c)
_rl_readstr_restore (cxt);
return -1;
}
cxt->lastc = rl_line_buffer[rl_point - 1]; /* preserve prevc */
cxt->lastc = (rl_point > 0) ? rl_line_buffer[rl_point - 1] : rl_line_buffer[0]; /* preserve prevc */
break;
case RETURN:
+6
View File
@@ -45,3 +45,9 @@ legal_alias_name (const char *string, int flags)
{
return (valid_alias_name (string, flags));
}
int
compat_init (void)
{
return 0;
}