]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
allow quoted-insert while reading readline search strings; force filename argument...
authorChet Ramey <chet.ramey@case.edu>
Tue, 14 Nov 2023 15:20:05 +0000 (10:20 -0500)
committerChet Ramey <chet.ramey@case.edu>
Tue, 14 Nov 2023 15:20:05 +0000 (10:20 -0500)
13 files changed:
CWRU/CWRU.chlog
builtins/enable.def
builtins/mkbuiltins.c
doc/bash.1
doc/bashref.texi
doc/version.texi
examples/loadables/csv.c
externs.h
lib/readline/isearch.c
lib/readline/search.c
lib/readline/terminal.c
lib/readline/text.c
lib/sh/compat.c

index 808a061c5526f3e4a207222cef9ecf95eeb9147b..ad9dd077f2973175027d35567f6624785c9a791b 100644 (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).
index 399c7fa34fb866f43fc09a4e5c5a19ac80447feb..bb49fe3185a7e2d40cca5a41f7051d927fa7efc4 100644 (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)
     {
index 658db05748fecc55bc0de295ccf054d21ff303ac..690a65c778c1177e28110324db78c9f45c1e6b7d 100644 (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
 };
 
index 901794c1e118af2032f3f905256c6363b9bf25f9..116bf1efaa84b3b3410196bf785fce84fe082241 100644 (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
index 41db2ed5d2467b40097025f3ce0af61555deaacf..033c0c15e0898c896395189724dcd80779221e90 100644 (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
index 2a42c2f3e9b1c00fab3cbd38d199bf02ad54c827..95c5c207b1b8cd82465141387db264e23f0011a6 100644 (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
index 9e7d1026a64dc43bd7b186b6d904520255cb4953..099fa8342d9c7784fe88c25e945ef2658406cd0c 100644 (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);
index 11916f9263e5422aacaafedfafa717cfbf731d5b..832ab203d2fd20657a4bf430e9c3c4344faca41a 100644 (file)
--- a/externs.h
+++ b/externs.h
@@ -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);
index 1cc8e806d08e77ec0daef1a04b950df7d4373306..07e76f1165e611ad54feaf7ce3b1d9b3ea76b480 100644 (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)
index 810ab419a338ff1a82a110ca99ea87749f0f5d4e..37db052ecc54b47daab724328e99402c8dca2d99 100644 (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;
index 2c13c402bac3a26880804a012e3c8857ddd8ecf0..67adc7b5f9caa97d8b3af28fc88ca9e5e41fb61e 100644 (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. */
index 933536add9f452451b63995277b18151361a9807..25e848492cd3c1b81a4703cdd63a5de273d10d1f 100644 (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:
index 0898ac58f4d3bbf862bbf58fe9d0aae9c1996c51..a0e4702b76895879e382fba61472a1997b3c1bbe 100644 (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;
+}