Skip to content

Commit

Permalink
prompt: do not evaluate "PROMPT_COMMAND" for subprompts
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Sep 22, 2021
1 parent 2710b23 commit 08e903e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions memo/ChangeLog.md
Expand Up @@ -101,6 +101,7 @@
- main: show notifications against debug versions of Bash `#D1612` 8f974aa
- term: update `vte` identification `#D1620` 00e74d8
- edit: suppress only `stderr` with `internal_suppress_bash_output` (motivated by rashil2000) `#D1646` a30887f
- prompt: do not evaluate `PROMPT_COMMAND` for subprompts `#D1654` 0000000

## Fixes

Expand Down
8 changes: 8 additions & 0 deletions note.txt
Expand Up @@ -5374,6 +5374,14 @@ bash_tips

2021-09-22

* prompt: do not evaluate PROMPT_COMMAND for subprompts [#D1654]

#D1654 で観察していて気づいたが現在のコードだと subprompt に対しても
PROMPT_COMMAND を実行している。それは何だか変なので subprompt に対しては
PROMPT_COMMAND は実行しない様に修正する。

これは後で ble-0.3 にも適用したいので commit を分ける事にする。

* vi: ? や / が動かなくなっている [#D1653]

* 表示が滅茶苦茶になってしまう。
Expand Down
30 changes: 15 additions & 15 deletions src/edit.sh
Expand Up @@ -1437,12 +1437,14 @@ function ble/prompt/update {

# Update PS1 in PROMPT_COMMAND / PRECMD
local version=$COLUMNS:$_ble_edit_lineno:$_ble_history_count
if [[ $_ble_prompt_hash != "$version" && $opts != *:leave:* ]]; then
if ble/prompt/update/.has-prompt_command || blehook/has-hook PRECMD; then
ble-edit/restore-PS1
ble/prompt/update/.eval-prompt_command
ble-edit/exec:gexec/invoke-hook-with-setexit PRECMD
ble-edit/adjust-PS1
if ((_ble_textarea_panel==0)); then # 補助プロンプトに対しては PROMPT_COMMAND は実行しない
if [[ $_ble_prompt_hash != "$version" && $opts != *:leave:* ]]; then
if ble/prompt/update/.has-prompt_command || blehook/has-hook PRECMD; then
ble-edit/restore-PS1
ble/prompt/update/.eval-prompt_command
ble-edit/exec:gexec/invoke-hook-with-setexit PRECMD
ble-edit/adjust-PS1
fi
fi
fi

Expand Down Expand Up @@ -1483,16 +1485,14 @@ function ble/prompt/update {
((_ble_textarea_panel==0)) || { [[ $dirty ]]; return $?; }

# bleopt prompt_rps1
if ((_ble_textarea_panel==0)); then
if [[ :$opts: == *:leave:* && ! $rps1f && $bleopt_prompt_rps1_transient ]]; then
# prompt_rps1_transient による消去 (以前の大きさを保持)
[[ ${_ble_prompt_rps1_data[10]} ]] && dirty=1 rps1_enabled=erase
if [[ :$opts: == *:leave:* && ! $rps1f && $bleopt_prompt_rps1_transient ]]; then
# prompt_rps1_transient による消去 (以前の大きさを保持)
[[ ${_ble_prompt_rps1_data[10]} ]] && dirty=1 rps1_enabled=erase

else
[[ $prompt_rps1 || ${_ble_prompt_rps1_data[10]} ]] &&
ble/prompt/unit#update _ble_prompt_rps1 && dirty=1
[[ ${_ble_prompt_rps1_data[10]} ]] && rps1_enabled=1
fi
else
[[ $prompt_rps1 || ${_ble_prompt_rps1_data[10]} ]] &&
ble/prompt/unit#update _ble_prompt_rps1 && dirty=1
[[ ${_ble_prompt_rps1_data[10]} ]] && rps1_enabled=1
fi

# bleopt prompt_xterm_title
Expand Down

0 comments on commit 08e903e

Please sign in to comment.