Skip to content

Commit

Permalink
complete: work around bash-completion bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed May 6, 2021
1 parent 7b63c60 commit 9d4ad56
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
15 changes: 15 additions & 0 deletions lib/core-complete.sh
Expand Up @@ -2385,8 +2385,23 @@ function ble/complete/progcomp/.compgen {
ble/array#push compoptions "-$c" "$o" ;;
(F)
comp_func=${compargs[iarg++]}

# Workarounds for third-party plugins
[[ $comp_func == _fzf_* ]] &&
ble-import contrib/fzf-completion
if ble/is-function _quote_readline_by_ref; then
# Fix bash_completion
function _quote_readline_by_ref {
if [[ $1 == \'* ]]; then
printf -v "$2" %s "${1:1}"
else
printf -v "$2" %q "$1"
[[ ${!2} == \$* ]] && eval $2=${!2}
fi
}
ble/function#suppress-stderr _filedir
fi

ble/array#push compoptions "-$c" ble/complete/progcomp/.compgen-helper-func ;;
(C)
comp_prog=${compargs[iarg++]}
Expand Down
1 change: 1 addition & 0 deletions memo/ChangeLog.md
Expand Up @@ -84,6 +84,7 @@
- syntax: fix a bug that `eval() { :; }`, `declare() { :; }` are not treated as function definition `#D1529` 0000000
- decode: fix a hang on attach failure by cache corruption `#D1531` 0000000
- edit, etc: add workarounds for `localvar_inherit` `#D1532` 0000000
- complete: work around bash-completion bugs `#D1533` 0000000

## Compatibility

Expand Down
17 changes: 16 additions & 1 deletion note.txt
Expand Up @@ -1255,11 +1255,17 @@ bash_tips


*******************************************************************************
bug-bash
bug-bash, third-party bugs
-------------------------------------------------------------------------------

2021-05-06

* bash-completion
https://github.com/akinomyoga/ble.sh/issues/97
Ref #D1533

python のテストを自分で実装したりしなければならず面倒である。

* bug-bash localvar_inherit: dynamic variables の性質も継承されるのは意図的か。
Ref #D1532

Expand Down Expand Up @@ -4343,6 +4349,15 @@ bash_tips

2021-05-06

* complete: bash-completion bug workarounds (reported by oc1024) [#D1533]
https://github.com/akinomyoga/ble.sh/issues/97

自分の手許でも色々エラーメッセージが出てうるさい。

bash-completion で修正を掛けるのは面倒だし時間がかかりそう。更に、各種
distribution に波及する迄に更に時間もかかりそうなので取り敢えず暫定的に、
ble.sh の側で bash-completion の実装を上書きする事にしてしまう。

* 2021-04-06 localvar_inherit で動かなくなっている [#D1532]

或いは元から動いた事はなかった可能性も?
Expand Down
8 changes: 5 additions & 3 deletions src/util.sh
Expand Up @@ -2497,11 +2497,13 @@ function ble/function#suppress-stderr {
return 2
fi

local def; ble/function#getdef "$name"
builtin eval "ble/function#suppress-stderr:$def"
# 重複して suppress-stderr した時の為、未定義の時のみ実装を待避
local lambda=ble/function#suppress-stderr:$name
if ! ble/is-function "$lambda"; then
local def; ble/function#getdef "$name"
builtin eval "ble/function#suppress-stderr:$def"
fi

local q=\' Q="'\''"
builtin eval "function $name { $lambda \"\$@\" 2>/dev/null; }"
return 0
}
Expand Down

0 comments on commit 9d4ad56

Please sign in to comment.