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 Sep 23, 2021
1 parent e397120 commit 40827ef
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
5 changes: 3 additions & 2 deletions lib/core-complete-def.sh
Expand Up @@ -18,8 +18,9 @@ _ble_complete_insert_hook=()

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=()
if ((_ble_bash>=40200)); then
declare -gA _ble_complete_sabbrev
_ble_complete_sabbrev=()
elif ((_ble_bash>=40000&&!_ble_bash_loaded_in_function)); then
declare -A _ble_complete_sabbrev=()
fi
Expand Down
2 changes: 1 addition & 1 deletion lib/core-complete.sh
Expand Up @@ -4296,7 +4296,7 @@ function ble/complete/sabbrev/.print-definition {
## @param[in] key
## @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
function ble/complete/sabbrev/register {
local key=$1 value=$2
_ble_complete_sabbrev[$key]=$value
Expand Down
10 changes: 6 additions & 4 deletions lib/core-syntax-def.sh
Expand Up @@ -70,12 +70,14 @@ ble/function#try ble/util/idle.push ble/syntax/import ||

bleopt/declare -v filename_ls_colors ''

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
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=()
if ((_ble_bash>=40200)); then
declare -gA _ble_syntax_highlight_filetype
_ble_syntax_highlight_filetype=()
declare -gA _ble_syntax_highlight_lscolors_ext
_ble_syntax_highlight_lscolors_ext=()
else
declare -A _ble_syntax_highlight_filetype=()
declare -A _ble_syntax_highlight_lscolors_ext=()
Expand Down
4 changes: 2 additions & 2 deletions lib/core-syntax.sh
Expand Up @@ -5161,7 +5161,7 @@ function ble/syntax/highlight/cmdtype/.impl {
## @param[in] word
## シェル展開・クォート除去を実行する前の文字列を指定します。
## @var[out] type
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
# Note: 連想配列 _ble_syntax_highlight_filetype は core-syntax-def.sh で先に定義される。

_ble_syntax_highlight_filetype_version=-1
Expand Down Expand Up @@ -5262,7 +5262,7 @@ function ble/syntax/highlight/ls_colors/.clear {
## 関数 ble/syntax/highlight/ls_colors/.read-extension key
## @param[in] key
## @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
# 連想配列による実装
function ble/syntax/highlight/ls_colors/.register-extension {
local key=$1 value=$2
Expand Down
7 changes: 4 additions & 3 deletions src/decode.sh
Expand Up @@ -96,12 +96,13 @@ _ble_decode_FunctionKeyBase=0x110000
##
## 関数 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=()
if ((_ble_bash>=40200)); then
declare -gA _ble_decode_kbd__k2c
_ble_decode_kbd__k2c=()
else
declare -A _ble_decode_kbd__k2c=()
fi
Expand Down

0 comments on commit 40827ef

Please sign in to comment.