Skip to contentSkip to conversation

bash: Disable bracketed input by default

PATCH In review Joshua Watt 2 participants 2 messages Feb 4, 2021 – Feb 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bash: Disable bracketed input by default

Bash 5.1 enabled bracketed input mode by default, but this causes a lot of problems with automated testing as it can inject a lot of control sequences into non-interactive output. Disable it to cleanup the output an preserve the pre-5.1 behavior

---
 meta/recipes-extended/bash/bash.inc | 4 ++++
 1 file changed, 4 insertions(+)
meta/recipes-extended/bash/bash.inc +4 -0
index bc737acd63..db326660ea 100644
@@ -17,6 +17,10 @@ CFLAGS += "-DNON_INTERACTIVE_LOGIN_SHELLS"
 # This can vary depending upon the host
 CFLAGS += "-DHEREDOC_PIPESIZE=65536"
 
+# Disable bracketed paste mode by default (enabled by default in bash 5.1). It
+# causes a lot of garbage in non-interactive shells
+CFLAGS += "-DBRACKETED_PASTE_DEFAULT=0"
+
 ALTERNATIVE_${PN} = "bash sh"
 ALTERNATIVE_LINK_NAME[bash] = "${base_bindir}/bash"
 ALTERNATIVE_TARGET[bash] = "${base_bindir}/bash"
Signature · 1 line
2.30.0
#1 lore raw
Quoted 15 lines · Joshua Watt

Bash 5.1 enabled bracketed input mode by default, but this causes a lot of problems with automated testing as it can inject a lot of control sequences into non-interactive output. Disable it to cleanup the output an preserve the pre-5.1 behavior

---
  meta/recipes-extended/bash/bash.inc | 4 ++++
  1 file changed, 4 insertions(+)
meta/recipes-extended/bash/bash.inc +0 -0
index bc737acd63..db326660ea 100644

meta/recipes-extended/bash/bash.inc CFLAGS += "-DNON_INTERACTIVE_LOGIN_SHELLS" · line 23

Quoted 7 lines
meta/recipes-extended/bash/bash.inc +4 -0
@@ -17,6 +17,10 @@ CFLAGS += "-DNON_INTERACTIVE_LOGIN_SHELLS"
  # This can vary depending upon the host
  CFLAGS += "-DHEREDOC_PIPESIZE=65536"
 
+# Disable bracketed paste mode by default (enabled by default in bash 5.1). It
+# causes a lot of garbage in non-interactive shells
+CFLAGS += "-DBRACKETED_PASTE_DEFAULT=0"
+

Reverting default upstream behaviour seems dodgy but in this case the feature is marked as experimental (see below) so I think it's fine.

See:
https://git.savannah.gnu.org/cgit/bash.git/commit/?id=8868edaf2
and search for:
+int _rl_enable_bracketed_paste = BRACKETED_PASTE_DEFAULT;
and then
_rl_enable_bracketed_paste

(patch section shown below)

Joshua,
Will you ask that upstream turns this off by default?

../Randy

Sorry for the line wrapping:

+ case ESC:
+ /* XXX - experimental code to allow users to bracketed-paste into the

+        search string. Similar code is in isearch.c:_rl_isearch_dispatch().
+        The difference here is that the bracketed paste sometimes doesn't
+        paste everything, so checking for the prefix and the suffix in the
+        input queue doesn't work well. We just have to check to see if the
+        number of chars in the input queue is enough for the bracketed paste
+        prefix and hope for the best. */

+ if (_rl_enable_bracketed_paste && ((n = _rl_nchars_available ()) >= (BRACK_PASTE_SLEN-1)))
+ {
+ if (_rl_read_bracketed_paste_prefix (c) == 1)
+ rl_bracketed_paste_begin (1, c);
+ else
+ {
+ c = rl_read_key (); /* get the ESC that got pushed back */
+ _rl_insert_char (1, c);
+ }
+ }
+ else
+ _rl_insert_char (1, c);
+ break;
+

Quoted 8 lines
meta/recipes-extended/bash/bash.inc +0 -0
  ALTERNATIVE_${PN} = "bash sh"
  ALTERNATIVE_LINK_NAME[bash] = "${base_bindir}/bash"
  ALTERNATIVE_TARGET[bash] = "${base_bindir}/bash"
Signature · 2 lines
# Randy MacLeod
# Wind River Linux