Skip to content

Commit

Permalink
edit: fix a bug that the shell hangs with "source ble.sh && PROMPT_CO…
Browse files Browse the repository at this point in the history
…MMAND="
  • Loading branch information
akinomyoga committed Jan 18, 2020
1 parent a82f961 commit 3031007
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
7 changes: 5 additions & 2 deletions ble.pp
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ function ble/base/attach-from-PROMPT_COMMAND {
[[ $PROMPT_COMMAND != ble/base/attach-from-PROMPT_COMMAND ]] && local PROMPT_COMMAND
PROMPT_COMMAND=$_ble_base_attach_PROMPT_COMMAND
ble-edit/prompt/update/.eval-prompt_command
blehook PRECMD-=ble/base/attach-from-PROMPT_COMMAND

# 既に attach 状態の時は処理はスキップ
[[ $_ble_base_attach_from_prompt ]] || return 0
Expand Down Expand Up @@ -873,8 +874,10 @@ function ble/base/process-blesh-arguments {
(prompt) _ble_base_attach_PROMPT_COMMAND=$PROMPT_COMMAND
_ble_base_attach_from_prompt=1
PROMPT_COMMAND=ble/base/attach-from-PROMPT_COMMAND
[[ $_ble_edit_detach_flag == reload ]] &&
_ble_edit_detach_flag= ;;
if [[ $_ble_edit_detach_flag == reload ]]; then
_ble_edit_detach_flag=prompt-attach
blehook PRECMD+=ble/base/attach-from-PROMPT_COMMAND
fi ;;
esac
[[ $flags != *E* ]]
}
Expand Down
4 changes: 4 additions & 0 deletions memo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3821,6 +3821,10 @@ bash_tips
その時に EOL 補正が入ってしまっているのである。
対症療法的ではあるが _ble_edit_exec_inside_prologue= を設定する。

? よく考えるとこれだと prompt に失敗した時にやはり変な状態になるのでは。
→実際に確かめてみたところ駄目になった。追加で修正する必要がある。
修正した。

* 2019-02-09 manual: 英語版 [#D1222]
取り敢えず完成した。

Expand Down
10 changes: 7 additions & 3 deletions src/edit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,10 @@ function ble-edit/prompt/update {
local cache_d= cache_t= cache_A= cache_T= cache_at= cache_j= cache_wd=

# update PS1
if [[ $PROMPT_COMMAND ]]; then
if [[ $PROMPT_COMMAND ]] || blehook/has-hook PRECMD; then
ble-edit/restore-PS1
ble-edit/prompt/update/.eval-prompt_command
[[ $PROMPT_COMMAND ]] &&
ble-edit/prompt/update/.eval-prompt_command
ble-edit/exec:gexec/invoke-hook-with-setexit PRECMD
ble-edit/adjust-PS1
fi
Expand Down Expand Up @@ -7102,7 +7103,10 @@ function ble-edit/bind/.check-detach {
ble-detach
fi

if [[ $_ble_edit_detach_flag ]]; then
# reload & prompt-attach の時は素通り (detach 後の処理は不要)
[[ $_ble_edit_detach_flag == prompt-attach ]] && return 1

if [[ $_ble_edit_detach_flag || ! $_ble_attached ]]; then
type=$_ble_edit_detach_flag
_ble_edit_detach_flag=
#ble/term/visible-bell ' Bye!! '
Expand Down
4 changes: 4 additions & 0 deletions src/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,10 @@ function blehook {
}
blehook/.compatibility-ble-0.3

function blehook/has-hook {
eval "local count=\${#_ble_hook_h_$1[@]}"
((count))
}
function blehook/invoke {
local lastexit=$? FUNCNEST=
((_ble_hook_c_$1++))
Expand Down

0 comments on commit 3031007

Please sign in to comment.