From d7d2a23436b61374b9838d21189533f9249d0593 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sun, 16 May 2021 09:01:21 +0900 Subject: [PATCH] global: work around empty cache files by "tmux-resurrect" --- keymap/emacs.sh | 3 ++- keymap/vi.sh | 3 ++- keymap/vi_digraph.sh | 3 ++- src/decode.sh | 7 ++++--- src/util.sh | 6 +++--- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/keymap/emacs.sh b/keymap/emacs.sh index 6f53c159..e65bc728 100644 --- a/keymap/emacs.sh +++ b/keymap/emacs.sh @@ -241,7 +241,8 @@ function ble-decode/keymap:emacs/define { function ble-decode/keymap:emacs/initialize { local fname_keymap_cache=$_ble_base_cache/keymap.emacs - if [[ $fname_keymap_cache -nt $_ble_base/keymap/emacs.sh && + if [[ -s $fname_keymap_cache && + $fname_keymap_cache -nt $_ble_base/keymap/emacs.sh && $fname_keymap_cache -nt $_ble_base/lib/init-cmap.sh ]]; then source "$fname_keymap_cache" && return fi diff --git a/keymap/vi.sh b/keymap/vi.sh index 57c7734b..33d25161 100644 --- a/keymap/vi.sh +++ b/keymap/vi.sh @@ -7772,7 +7772,8 @@ function ble-decode/keymap:vi_cmap/define { function ble-decode/keymap:vi/initialize { local fname_keymap_cache=$_ble_base_cache/keymap.vi - if [[ $fname_keymap_cache -nt $_ble_base/keymap/vi.sh && + if [[ -s $fname_keymap_cache && + $fname_keymap_cache -nt $_ble_base/keymap/vi.sh && $fname_keymap_cache -nt $_ble_base/lib/init-cmap.sh ]]; then source "$fname_keymap_cache" && return fi diff --git a/keymap/vi_digraph.sh b/keymap/vi_digraph.sh index 428ef420..6691ea00 100644 --- a/keymap/vi_digraph.sh +++ b/keymap/vi_digraph.sh @@ -49,7 +49,8 @@ function ble-decode/keymap:vi_digraph/define { function ble-decode/keymap:vi_digraph/initialize { local fname_keymap_cache=$_ble_base_cache/keymap.vi_digraph - if [[ $fname_keymap_cache -nt $_ble_base/keymap/vi_digraph.sh && + if [[ -s $fname_keymap_cache && + $fname_keymap_cache -nt $_ble_base/keymap/vi_digraph.sh && $fname_keymap_cache -nt $_ble_base/keymap/vi_digraph.txt ]]; then source "$fname_keymap_cache" return diff --git a/src/decode.sh b/src/decode.sh index ff419bd2..1583d8a7 100644 --- a/src/decode.sh +++ b/src/decode.sh @@ -2050,7 +2050,7 @@ function ble-decode-bind/cmap/initialize { local init=$_ble_base/lib/init-cmap.sh local dump=$_ble_base_cache/cmap+default.$_ble_decode_kbd_ver.$TERM.dump - if [[ $dump -nt $init ]]; then + if [[ -s $dump && $dump -nt $init ]]; then source "$dump" else ble-edit/info/immediate-show text 'ble.sh: generating "'"$dump"'"...' @@ -2071,7 +2071,8 @@ function ble-decode-bind/cmap/initialize { # 3文字以上 bind/unbind ソースの生成 local fbinder=$_ble_base_cache/cmap+default.binder-source _ble_decode_bind_fbinder=$fbinder - if ! [[ $_ble_decode_bind_fbinder -nt $init ]]; then + if ! [[ -s $_ble_decode_bind_fbinder.bind && $_ble_decode_bind_fbinder.bind -nt $init && + -s $_ble_decode_bind_fbinder.unbind && $_ble_decode_bind_fbinder.unbind -nt $init ]]; then ble-edit/info/immediate-show text 'ble.sh: initializing multichar sequence binders... ' ble-decode-bind/cmap/.generate-binder-template >| "$fbinder" binder=ble-decode-bind/cmap/.emit-bindx source "$fbinder" >| "$fbinder.bind" @@ -2198,7 +2199,7 @@ function ble-decode-bind/.generate-source-to-unbind-default/.process { function ble-decode/bind { local file=$_ble_base_cache/ble-decode-bind.$_ble_bash.$bleopt_input_encoding.bind - [[ $file -nt $_ble_base/lib/init-bind.sh ]] || source "$_ble_base/lib/init-bind.sh" + [[ -s $file && $file -nt $_ble_base/lib/init-bind.sh ]] || source "$_ble_base/lib/init-bind.sh" # * 一時的に 'set convert-meta off' にする。 # diff --git a/src/util.sh b/src/util.sh index c2b86752..352ea410 100644 --- a/src/util.sh +++ b/src/util.sh @@ -2735,10 +2735,10 @@ function ble-term/.initialize { _ble_term_IFS=$' \t\n' _ble_term_CR=$'\r' - if [[ $_ble_base/lib/init-term.sh -nt $_ble_base_cache/$TERM.term ]]; then - source "$_ble_base/lib/init-term.sh" - else + if [[ -s $_ble_base_cache/$TERM.term && $_ble_base_cache/$TERM.term -nt $_ble_base/lib/init-term.sh ]]; then source "$_ble_base_cache/$TERM.term" + else + source "$_ble_base/lib/init-term.sh" fi ble/string#reserve-prototype "$_ble_term_it"