| 1 |
From abd7b3cad015c13029adb51e7e07d8106c2d1cf3 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Koichi Murase <[email protected]> |
| 3 |
Date: Sun, 10 Dec 2023 03:18:34 +0900 |
| 4 |
Subject: [PATCH 1/4] [reject] nocasematch protection (extras) |
| 5 |
|
| 6 |
--- |
| 7 |
contrib | 2 +- |
| 8 |
lib/core-complete.sh | 27 ++++++++++++++++++++++----- |
| 9 |
src/edit.sh | 8 ++++---- |
| 10 |
3 files changed, 27 insertions(+), 10 deletions(-) |
| 11 |
|
| 12 |
diff --git a/contrib b/contrib |
| 13 |
index 18d889e1..f3d52a35 160000 |
| 14 |
--- a/contrib |
| 15 |
+++ b/contrib |
| 16 |
@@ -1 +1 @@ |
| 17 |
-Subproject commit 18d889e1906b4b8d3b8a27a320856cbf2f9ae345 |
| 18 |
+Subproject commit f3d52a35f78379faf5dfdbed88d225d92d479dfc |
| 19 |
diff --git a/lib/core-complete.sh b/lib/core-complete.sh |
| 20 |
index 4520730e..59d8cdf7 100644 |
| 21 |
--- a/lib/core-complete.sh |
| 22 |
+++ b/lib/core-complete.sh |
| 23 |
@@ -3265,6 +3265,7 @@ function ble/complete/progcomp/.compgen-helper-prog { |
| 24 |
## compopt を上書きして -o/+o option を読み取る為の関数です。 |
| 25 |
## |
| 26 |
## OPTION |
| 27 |
+## |
| 28 |
## ble/syntax-raw |
| 29 |
## 生成した候補をそのまま挿入する事を示します。 |
| 30 |
## |
| 31 |
@@ -3272,6 +3273,9 @@ function ble/complete/progcomp/.compgen-helper-prog { |
| 32 |
## ble.sh の既定の候補生成 (候補が生成されなかった時の既定の候補生成、お |
| 33 |
## よび、sabbrev 候補生成) を抑制します。 |
| 34 |
## |
| 35 |
+## Note: OPTION は大文字・小文字を区別できない場合でも一意になる様に名前をつ |
| 36 |
+## ける様にする。Bash 4.4 以降で ${var/pat} が shopt -s nocasematch に影響を |
| 37 |
+## 受けるため。 |
| 38 |
function ble/complete/progcomp/compopt { |
| 39 |
# Note: Bash補完以外から builtin compopt を呼び出しても |
| 40 |
# エラーになるので呼び出さない事にした (2019-02-05) |
| 41 |
@@ -3820,8 +3824,7 @@ function ble/complete/progcomp/.compgen { |
| 42 |
# Note #D1760: complete -D 以外の時でも 124 が返された時再試行する。 |
| 43 |
if [[ $progcomp_retry && ! $_ble_complete_retry_guard ]]; then |
| 44 |
local _ble_complete_retry_guard=1 |
| 45 |
- opts=:$opts: |
| 46 |
- opts=${opts//:default:/:} |
| 47 |
+ ble/opts#remove opts default |
| 48 |
ble/complete/progcomp/.compgen "$opts" |
| 49 |
return "$?" |
| 50 |
fi |
| 51 |
@@ -9389,6 +9392,12 @@ function ble/cmdinfo/complete/yield-flag { |
| 52 |
local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked |
| 53 |
ble/complete/cand/yield.initialize mandb |
| 54 |
|
| 55 |
+ local dtor= |
| 56 |
+ if shopt -q nocasematch 2>/dev/null; then |
| 57 |
+ shopt -u nocasematch |
| 58 |
+ dtor='shopt -s nocasematch' |
| 59 |
+ fi |
| 60 |
+ |
| 61 |
# opts dedup |
| 62 |
local ret |
| 63 |
if [[ ${COMPV:1} ]] && ble/opts#extract-last-optarg "$opts" dedup "$flags"; then |
| 64 |
@@ -9397,16 +9406,23 @@ function ble/cmdinfo/complete/yield-flag { |
| 65 |
fi |
| 66 |
|
| 67 |
if ble/opts#extract-last-optarg "$opts" hasarg; then |
| 68 |
- [[ $COMPV == -*["$ret"]* ]] && return 1 |
| 69 |
+ if [[ $COMPV == -*["$ret"]* ]]; then |
| 70 |
+ builtin eval -- "$dtor" |
| 71 |
+ return 1 |
| 72 |
+ fi |
| 73 |
fi |
| 74 |
|
| 75 |
if [[ ! $flags ]]; then |
| 76 |
- [[ :$opts: == *:cancel-on-empty:* ]] && return 1 |
| 77 |
+ if [[ :$opts: == *:cancel-on-empty:* ]]; then |
| 78 |
+ builtin eval -- "$dtor" |
| 79 |
+ return 1 |
| 80 |
+ fi |
| 81 |
|
| 82 |
# 候補のフラグがもうない場合は現在の内容で一意確定 |
| 83 |
local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked |
| 84 |
ble/complete/cand/yield.initialize word |
| 85 |
ble/complete/cand/yield word "$COMPV" |
| 86 |
+ builtin eval -- "$dtor" |
| 87 |
return "$?" |
| 88 |
fi |
| 89 |
|
| 90 |
@@ -9418,7 +9434,7 @@ function ble/cmdinfo/complete/yield-flag { |
| 91 |
local entry fs=$_ble_term_FS |
| 92 |
for entry in "${ret[@]}"; do |
| 93 |
((cand_iloop++%bleopt_complete_polling_cycle==0)) && |
| 94 |
- ble/complete/check-cancel && return 148 |
| 95 |
+ ble/complete/check-cancel && { builtin eval -- "$dtor"; return 148; } |
| 96 |
local option=${entry%%$fs*} |
| 97 |
[[ $option == -? && ${option:1} == ["$flags"] ]] || continue |
| 98 |
ble/complete/cand/yield mandb.flag "$COMPV${option:1}" "$entry" |
| 99 |
@@ -9433,6 +9449,7 @@ function ble/cmdinfo/complete/yield-flag { |
| 100 |
for ((i=0;i<${#flags};i++)); do |
| 101 |
ble/complete/cand/yield mandb.flag "$COMPV${flags:i:1}" |
| 102 |
done |
| 103 |
+ builtin eval -- "$dtor" |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
diff --git a/src/edit.sh b/src/edit.sh |
| 108 |
index 5a6323ed..81297d4e 100644 |
| 109 |
--- a/src/edit.sh |
| 110 |
+++ b/src/edit.sh |
| 111 |
@@ -3680,12 +3680,12 @@ function ble/textarea#save-state { |
| 112 |
local layer names |
| 113 |
for layer in "${_ble_highlight_layer_list[@]}"; do |
| 114 |
local _ble_local_script=' |
| 115 |
- if [[ ${_ble_highlight_layer_LAYER_VARNAMES[@]-} ]]; then |
| 116 |
- ble/array#push vars "${_ble_highlight_layer_LAYER_VARNAMES[@]}" |
| 117 |
+ if [[ ${_ble_highlight_layer_LNAME_VARNAMES[@]-} ]]; then |
| 118 |
+ ble/array#push vars "${_ble_highlight_layer_LNAME_VARNAMES[@]}" |
| 119 |
else |
| 120 |
- ble/array#push vars "${!_ble_highlight_layer_LAYER_@}" |
| 121 |
+ ble/array#push vars "${!_ble_highlight_layer_LNAME_@}" |
| 122 |
fi' |
| 123 |
- builtin eval -- "${_ble_local_script//LAYER/$layer}" |
| 124 |
+ builtin eval -- "${_ble_local_script//LNAME/$layer}" |
| 125 |
done |
| 126 |
|
| 127 |
# _ble_textarea_* |
| 128 |
-- |
| 129 |
2.41.0 |
| 130 |
|