Skip to content

Commit

Permalink
decode: check "bind -X" first to store the original bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 27, 2019
1 parent 711cedb commit c5211af
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/decode.sh
Expand Up @@ -2076,11 +2076,12 @@ function ble-decode-bind/.generate-source-to-unbind-default {
# 1 ESC で始まる既存の binding を全て削除
# 2 bind を全て記録 at $$.bind.save
{
builtin bind -sp
if ((_ble_bash>=40300)); then
echo '__BINDX__'
builtin bind -X
fi
ble/bin/echo '__BINDP__'
builtin bind -sp
#%x
} | LC_ALL=C ble-decode-bind/.generate-source-to-unbind-default/.process

Expand All @@ -2092,7 +2093,7 @@ function ble-decode-bind/.generate-source-to-unbind-default/.process {
#%end.i
BEGIN {
APOS = apos "\\" apos apos;
mode = 0;
mode = 1;
}
function quote(text) {
Expand Down Expand Up @@ -2136,7 +2137,10 @@ function ble-decode-bind/.generate-source-to-unbind-default/.process {
}
}
mode == 0 && $0 ~ /^"/ {
/^__BINDP__$/ { mode = 1; next; }
/^__BINDX__$/ { mode = 2; next; }
mode == 1 && $0 ~ /^"/ {
# Workaround Bash-5.0 bug (cf #D1078)
sub(/^"\\C-\\\\\\"/, "\"\\C-\\\\\"");
sub(/^"\\C-\\"/, "\"\\C-\\\\\"");
Expand All @@ -2146,9 +2150,7 @@ function ble-decode-bind/.generate-source-to-unbind-default/.process {
print "builtin bind " quote($0) > "/dev/stderr";
}
/^__BINDX__$/ { mode = 1; }
mode == 1 && $0 ~ /^"/ {
mode == 2 && $0 ~ /^"/ {
output_bindr($0);
line = $0;
Expand All @@ -2166,7 +2168,7 @@ function ble-decode-bind/.generate-source-to-unbind-default/.process {
#% # escape には以下の種類がある: \C-a など \C-? \e \\ \"
#% # \n\r\f\t\v\b\a 等は使われない様だ。
#%if use_gawk
if (match(line, /^("([^"\\]|\\.)*":) "(([^"\\]|\\.)*)"/,captures) > 0) {
if (match(line, /^("([^"\\]|\\.)*":) "(([^"\\]|\\.)*)"/, captures) > 0) {
sequence = captures[1];
command = captures[3];
Expand Down

0 comments on commit c5211af

Please sign in to comment.