Skip to content

Commit

Permalink
progcomp: disable "command_not_found_handle" for "__load_completion"
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jul 9, 2022
1 parent 12c022b commit d5fe1d1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
8 changes: 4 additions & 4 deletions docs/ChangeLog.md
Expand Up @@ -163,7 +163,7 @@
- complete (`source:command/get-desc`): show function location and body `#D1788` 496e798
- edit (`ble-detach`): prepend a space to `stty sane` for `HISTIGNORE=' *'` `#D1796` 26b532e
- decode (`bind`): do not treat non-beginning `#` as comments `#D1820` 65c4138
- history: disable the history file when `HISTFILE` is empty `#D1836` XXXXXXX
- history: disable the history file when `HISTFILE` is empty `#D1836` 9549e83

## Fixes

Expand Down Expand Up @@ -363,7 +363,7 @@
- progcomp: work around the cobra V2 description hack (reported by SuperSandro2000) `#D1803` 71d0736
- complete: work around blocking `_scp_remote_files` and `_dnf` (reported by iantra) `#D1807` a4a779e 46f5c13
- history: work around broken timestamps in `HISTFILE` (reported by johnyaku) `#D1831` 5ef28eb
- progcomp: disable `command_not_found_handle` (reported by telometto, wisnoskij) `#D1834` 64d471a
- progcomp: disable `command_not_found_handle` (reported by telometto, wisnoskij) `#D1834` 64d471a XXXXXXX

## Internal changes and fixes

Expand Down Expand Up @@ -398,15 +398,15 @@
- test: clean up check failures by `make check` and `make scan` `#D1812` bb3e0a3
- util (`fd#alloc`): limit the search range of free fds `#D1813` 43be0e4 4c90072
- github/workflows: define an action for the nightly builds (contributed by uyha) `#D1814` a3082a0
- global: quote numbers for unexpected `IFS` `#D1835` XXXXXXX
- global: quote numbers for unexpected `IFS` `#D1835` 0179afc

## Contrib

- prompt-git: detect staged changes `#D1718` 2b48e31
- prompt-git: fix a bug that information is not updated on reload `#D1732` 361e9c5
- config/execmark: show exit status in a separate line `#D1828` 4d24f84
- prompt-git: ignore untracked files in submodules `#D1829` 4d24f84
- contrib/fzf-completion: fix integration (reported by ferdinandyb) `#D1837` XXXXXXX
- contrib/fzf-completion: fix integration (reported by ferdinandyb) `#D1837` 12c022b

<!---------------------------------------------------------------------------->
# ble-0.4.0-devel2
Expand Down
19 changes: 14 additions & 5 deletions lib/core-complete.sh
Expand Up @@ -3663,6 +3663,19 @@ function ble/complete/progcomp/.split-alias-words {
ret=("${words[@]:i}")
}

## @fn ble/complete/progcomp/.try-load-completion cmd
## bash-completion の loader を呼び出して遅延補完設定をチェックする。
function ble/complete/progcomp/.try-load-completion {
ble/is-function __load_completion || return 1

ble/function#push command_not_found_handle
__load_completion "$1" < /dev/null &>/dev/null; local ext=$?
ble/function#pop command_not_found_handle
((ext==0)) || return "$1"

builtin complete -p -- "$1" &>/dev/null
}

## @fn ble/complete/progcomp cmd opts
## 補完指定を検索して対応する補完関数を呼び出します。
## @var[in] comp_line comp_words comp_point comp_cword
Expand Down Expand Up @@ -3723,11 +3736,7 @@ function ble/complete/progcomp {
ble/complete/progcomp/.compline-rewrite-command "${qcmds[@]}" "${alias_args[@]}"
ble/complete/progcomp/.compgen "$opts"
return "$?"
elif
# bash-completion の loader を呼び出して遅延補完設定をチェックする。
ble/function#try __load_completion "${ucmd##*/}" &>/dev/null &&
builtin complete -p -- "${ucmd##*/}" &>/dev/null
then
elif ble/complete/progcomp/.try-load-completion "${ucmd##*/}"; then
ble/string#quote-word "${ucmd##*/}"; qcmds[0]=$ret
ble/complete/progcomp/.compline-rewrite-command "${qcmds[@]}" "${alias_args[@]}"
ble/complete/progcomp/.compgen "$opts"
Expand Down
20 changes: 20 additions & 0 deletions note.txt
Expand Up @@ -6566,6 +6566,26 @@ bash_tips

取り敢えず command_not_found_handle は function#push する事にする。

* 2022-07-09 未だ直っていないという (reported by telometto)
https://github.com/akinomyoga/ble.sh/issues/192#issuecomment-1179191747

先ずは PackageKit をインストールして動作を確認しようと思ったら既にインス
トールされている。然し /etc/profile.d/PackageKit.sh を確認してみても存在
していない。dnf search で検索してみると PackageKit-command-not-found とい
うのがあったのでそれを入れてみると入った。再現した。

確かに command_not_found が呼び出されて固まっている。然し、
command_not_found は一時的に無効化している筈。command_not_found_handle の
中から呼び出しの構造を調べてみた所、どうやら ble.sh が独自に
__load_completion を呼び出していてその時に command_not_found_handle が走っ
ている様だ。つまり、__load_completion を呼び出す時にも workaround で
command_not_found_handle を無効化する必要があるという事。

? __load_completion を呼び出す時には別に tty を封じてはいなかった様な気が
するが固まるのは何故だろうか。うーん。不思議だ。確認した所、&>/dev/null
で寧ろ入力ではなくて出力の方を組み替えている。なのに出力は出来て入力は
できないというのも変な事である。

2022-07-07

* main: fd 0, 1 が TTY かどうかのチェックが常に偽になっている [#D1833]
Expand Down

0 comments on commit d5fe1d1

Please sign in to comment.