Skip to content

Commit

Permalink
global: improve the workaround of bash-4.2 declare -gA by separate …
Browse files Browse the repository at this point in the history
…assignments
  • Loading branch information
akinomyoga committed May 24, 2021
1 parent a46fdaf commit 2408a20
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 43 deletions.
7 changes: 1 addition & 6 deletions lib/core-complete-def.sh
Expand Up @@ -18,12 +18,7 @@ function ble-sabbrev {
}

if ! declare -p _ble_complete_sabbrev &>/dev/null; then # reload #D0875
builtin unset -v _ble_complete_sabbrev
if ((_ble_bash>=40300)); then
declare -gA _ble_complete_sabbrev=()
elif ((_ble_bash>=40000&&!_ble_bash_loaded_in_function)); then
declare -A _ble_complete_sabbrev=()
fi
builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_complete_sabbrev}"
fi

#------------------------------------------------------------------------------
Expand Down
14 changes: 2 additions & 12 deletions lib/core-syntax-def.sh
Expand Up @@ -101,17 +101,7 @@ bleopt/declare -v highlight_timeout_sync 50
bleopt/declare -v highlight_timeout_async 5000
bleopt/declare -v syntax_eval_polling_interval 50

if ((_ble_bash>=40300||_ble_bash>=40000&&!_ble_bash_loaded_in_function)); then
builtin unset -v _ble_syntax_highlight_filetype
builtin unset -v _ble_syntax_highlight_lscolors_ext
if ((_ble_bash>=40300)); then
declare -gA _ble_syntax_highlight_filetype=()
declare -gA _ble_syntax_highlight_lscolors_ext=()
else
declare -A _ble_syntax_highlight_filetype=()
declare -A _ble_syntax_highlight_lscolors_ext=()
fi
fi

builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_highlight_filetype}"
builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_highlight_lscolors_ext}"
builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_bash_simple_eval}"
builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_syntax_bash_simple_eval_full}"
1 change: 1 addition & 0 deletions memo/ChangeLog.md
Expand Up @@ -93,6 +93,7 @@
- benchmark (`ble-measure`): work around a locale-dependent decimal point of `EPOCHREALTIME` (reported by 3ximus) `#D1460` 1aa471b
- global: work around bash-4.2 bug of `declare -gA` (reported by 0xC0ncord) `#D1470` 8856a04
- global: fix declaration of associative arrays for `ble-reload` (reported by 0xC0ncord) `#D1471` 3cae6e4
- global: use a better workaround of bash-4.2 `declare -gA` by separating assignment `#D1567` 0000000
- bind: work around broken `cmd_xmap` after switching the editing mode `#D1478` 8d354c1
- edit: clear graphic rendition on newlines and external commands `#D1479` 18bb2d5
- decode (rlfunc): work around incomplete bytes in keyseq (reported by onelittlehope) `#D1483` 3559658 beb0383 37363be
Expand Down
20 changes: 18 additions & 2 deletions note.txt
Expand Up @@ -1436,6 +1436,18 @@ bash_tips
0.5 ControlPanel/TUI Framework
0.4 progcolor

2021-05-24

* airline: 説明書を書く。theme の枠組みを整える

* themes の枠組みを整えたい気がする。現状だとユーザーがそれぞれ対応しなけれ
ばならない。面倒である。うーん。取り敢えず contrib に適当に加えてみるとい
うのも良い気がする。

* 説明に関しては theme を用意してそれを見てもらえれば十分の気がする。但し、
辞書に関しては theme は bash-4.1 以下でも動く様に gdict を使わなければな
らずややこしい。

2021-05-23

* menu-complete: SIGWINCH による info#panel::invalidate の際にメニュー項目の
Expand All @@ -1447,8 +1459,6 @@ bash_tips
* blehook internal hook は表示しない機能
* bleopt 既定値に戻す機能

* gA をその場で代入しなければ 4.2 でも大丈夫

* main: BASH_XTRACEFD による出力の抑制?

| 更に set -x についてもまた駄目になっているかもしれない。→試してみた所
Expand Down Expand Up @@ -4624,6 +4634,12 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2021-05-24

* global: gA をその場で代入しなければ 4.2 でも大丈夫 [#D1567]

共通なコードも多くあったので整理して纏める事にした。大分すっきりした。

2021-05-23

* contrib/git-prompt.sh の変数達は localvar_inherit で駄目なのではないか [#D1566]
Expand Down
9 changes: 2 additions & 7 deletions src/decode.sh
Expand Up @@ -114,15 +114,10 @@ _ble_decode_FunctionKeyBase=0x110000
##
## @fn ble-decode-kbd/.get-keycode keyname
## @var[out] ret
if ((_ble_bash>=40300||_ble_bash>=40000&&!_ble_bash_loaded_in_function)); then
if ((_ble_bash>=40200||_ble_bash>=40000&&!_ble_bash_loaded_in_function)); then
_ble_decode_kbd_ver=4
_ble_decode_kbd__n=0
builtin unset -v _ble_decode_kbd__k2c
if ((_ble_bash>=40300)); then
declare -gA _ble_decode_kbd__k2c=()
else
declare -A _ble_decode_kbd__k2c=()
fi
builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_decode_kbd__k2c}"
_ble_decode_kbd__c2k=()

function ble-decode-kbd/.set-keycode {
Expand Down
9 changes: 2 additions & 7 deletions src/history.sh
Expand Up @@ -781,13 +781,8 @@ if [[ ! ${_ble_builtin_history_initialized+set} ]]; then
## @fn ble/builtin/history/.add-rskip file delta
## @param[in] file
##
if ((_ble_bash>=40300||_ble_bash>=40000&&!_ble_bash_loaded_in_function)); then
builtin unset -v _ble_builtin_history_rskip_dict
if ((_ble_bash>=40300)); then
declare -gA _ble_builtin_history_rskip_dict=()
else
declare -A _ble_builtin_history_rskip_dict=()
fi
if ((_ble_bash>=40200||_ble_bash>=40000&&!_ble_bash_loaded_in_function)); then
builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_builtin_history_rskip_dict}"
function ble/builtin/history/.get-rskip {
local file=$1
rskip=${_ble_builtin_history_rskip_dict[$file]}
Expand Down
13 changes: 4 additions & 9 deletions src/util.sh
Expand Up @@ -1349,9 +1349,9 @@ fi

if ((_ble_bash>=40200||_ble_bash>=40000&&!_ble_bash_loaded_in_function)); then
if ((_ble_bash>=40200)); then
_ble_util_gdict_declare='declare -gA NAME=()'
_ble_util_gdict_declare='{ unset -v NAME; declare -gA NAME; NAME=(); }'
else
_ble_util_gdict_declare='declare -A NAME=()'
_ble_util_gdict_declare='{ unset -v NAME; declare -A NAME=(); }'
fi
function ble/gdict#set { ble/dict#set "$@"; }
function ble/gdict#get { ble/dict#get "$@"; }
Expand Down Expand Up @@ -1582,13 +1582,8 @@ _ble_builtin_trap_reserved=()
_ble_builtin_trap_handlers=()
_ble_builtin_trap_DEBUG=
_ble_builtin_trap_inside=
if ((_ble_bash>=40300||_ble_bash>=40000&&!_ble_bash_loaded_in_function)); then
builtin unset -v _ble_builtin_trap_n2i
if ((_ble_bash>=40300)); then
declare -gA _ble_builtin_trap_n2i=()
else
declare -A _ble_builtin_trap_n2i=()
fi
if ((_ble_bash>=40200||_ble_bash>=40000&&!_ble_bash_loaded_in_function)); then
builtin eval -- "${_ble_util_gdict_declare//NAME/_ble_builtin_trap_n2i}"
function ble/builtin/trap/.register {
local index=$1 name=$2
_ble_builtin_trap_signames[index]=$name
Expand Down

0 comments on commit 2408a20

Please sign in to comment.