Skip to content

Commit

Permalink
make (scan): clean up check failures
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jun 13, 2022
1 parent 022d38b commit bb3e0a3
Show file tree
Hide file tree
Showing 10 changed files with 318 additions and 295 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Expand Up @@ -377,6 +377,7 @@
- test: save the test log to a file `#D1735` d8e6ea7
- benchmark: improve determination of the base time `#D1737` ad866c1
- main: support `bleopt debug_xtrace` (requested by SuperSandro2000) `#D1810` XXXXXXX
- test: clean up check failures by `make check` and `make scan` `#D1812` XXXXXXX

## Contrib

Expand Down
40 changes: 20 additions & 20 deletions lib/core-complete.sh
Expand Up @@ -1194,7 +1194,7 @@ function ble/complete/action/complete.close-quotation {
##
## Example:
##
## local "${_ble_complete_quote_insert_varnames[@]/%/=}" # WA #D1570 safe
## local "${_ble_complete_quote_insert_varnames[@]/%/=}" # WA #D1570 checked
## ble/complete/action/quote-insert.initialize "$action"
## for INSERT; do
## ble/complete/action/quote-insert "$action"
Expand Down Expand Up @@ -1281,7 +1281,7 @@ function ble/complete/action/quote-insert.initialize {

function ble/complete/action/quote-insert {
if [[ ! $quote_action ]]; then
local "${_ble_complete_quote_insert_varnames[@]/%/=}" # WA #D1570 safe
local "${_ble_complete_quote_insert_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/action/quote-insert.initialize "${1:-plain}"
fi

Expand Down Expand Up @@ -2116,7 +2116,7 @@ function ble/complete/cand/yield-filenames {
done

[[ $FIGNORE ]] && local flag_force_fignore=1
local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize "$action"
ble/complete/cand/yield.batch "$action"
}
Expand Down Expand Up @@ -2203,7 +2203,7 @@ function ble/complete/source:wordlist {
[[ $opt_noword ]] && action=substr
[[ $opt_raw ]] && action=literal-$action

local cand "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local cand "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize "$action"
for cand; do
[[ $cand == "$COMPV"* ]] && ble/complete/cand/yield "$action" "$cand"
Expand Down Expand Up @@ -2393,7 +2393,7 @@ function ble/complete/source:command {

ble/complete/source/test-limit ${#arr[@]} || return 1

local action=command "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local action=command "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize "$action"

# 無効 keyword, alias 判定用
Expand Down Expand Up @@ -2714,7 +2714,7 @@ function ble/complete/source:fd {
local comp_filter_type=head

local old_cand_count=$cand_count
local action=word "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local action=word "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize "$action"
ble/complete/cand/yield "$action" -
if [[ -d /proc/self/fd ]]; then
Expand Down Expand Up @@ -3547,7 +3547,7 @@ function ble/complete/progcomp/.compgen {

local old_cand_count=$cand_count

local action=progcomp "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local action=progcomp "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize "$action"
if [[ $flag_mandb ]]; then
local -a entries; entries=("${cands[@]}")
Expand All @@ -3567,9 +3567,9 @@ function ble/complete/progcomp/.compgen {
else
[[ $progcomp_prefix ]] &&
if ((_ble_bash>=40300)) && ! shopt -q compat42; then
cands=("${cands[@]/#/"$progcomp_prefix"}") # WA #D1570 #D1751 safe
cands=("${cands[@]/#/"$progcomp_prefix"}") # WA #D1570 #D1751 checked
else
cands=("${cands[@]/#/$progcomp_prefix}") # WA #D1570 #D1738 safe
cands=("${cands[@]/#/$progcomp_prefix}") # WA #D1570 #D1738 checked
fi
fi
ble/complete/cand/yield.batch "$action" "$comp_opts"
Expand Down Expand Up @@ -4873,7 +4873,7 @@ function ble/complete/source:option {
# "--" や非オプション引数など、オプション無効化条件をチェック
ble/complete/source:option/.is-option-context "${prev_args[@]}" || return 1

local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize mandb
local entry fs=$_ble_term_FS has_desc=
for entry in "${entries[@]}"; do
Expand Down Expand Up @@ -5000,7 +5000,7 @@ function ble/complete/source:argument {
[[ :$comp_type: != *:[maA]:* && $value =~ ^.+/ ]] &&
COMP_PREFIX=$prefix${BASH_REMATCH[0]}

local ret cand "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local ret cand "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/source:file/.construct-pathname-pattern "$value"
ble/complete/util/eval-pathname-expansion "$ret"; (($?==148)) && return 148
ble/complete/source/test-limit ${#ret[@]} || return 1
Expand Down Expand Up @@ -5036,7 +5036,7 @@ function ble/complete/source/compgen {
# 既に完全一致している場合は、より前の起点から補完させるために省略
[[ $1 != '=' && ${#arr[@]} == 1 && $arr == "$COMPV" ]] && return 0

local cand "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local cand "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize "$action"
for cand in "${arr[@]}"; do
((cand_iloop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && return 148
Expand Down Expand Up @@ -5162,7 +5162,7 @@ function ble/complete/source:glob {
ble/complete/source/eval-simple-word "$pattern*"; (($?==148)) && return 148
fi

local cand action=file "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local cand action=file "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize "$action"
for cand in "${ret[@]}"; do
((cand_iloop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && return 148
Expand All @@ -5188,7 +5188,7 @@ function ble/complete/source:dynamic-history {
local rex_wordbreaks='['$wordbreaks']'
ble/util/assign-array ret 'HISTTIMEFORMAT= builtin history | ble/bin/grep -Eo "$rex_needle" | ble/bin/sed "s/^$rex_wordbreaks//" | ble/bin/sort -u'

local cand action=literal-word "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local cand action=literal-word "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize "$action"
for cand in "${ret[@]}"; do
((cand_iloop++%bleopt_complete_polling_cycle==0)) && ble/complete/check-cancel && return 148
Expand Down Expand Up @@ -6193,7 +6193,7 @@ function ble/complete/menu/generate-candidates-from-menu {
# remaining candidates
cand_count=${#_ble_complete_menu_items[@]}
cand_cand=() cand_word=() cand_pack=()
local pack "${_ble_complete_cand_varnames[@]/%/=}" # #D1570 WA checked
local pack "${_ble_complete_cand_varnames[@]/%/=}" # WA #D1570 checked
for pack in "${_ble_complete_menu_items[@]}"; do
ble/complete/cand/unpack "$pack"
ble/array#push cand_cand "$CAND"
Expand Down Expand Up @@ -7021,7 +7021,7 @@ function ble/complete/menu-filter/.filter-candidates {
cand_pack=()

local iloop=0 interval=$bleopt_complete_polling_cycle
local filter_type pack "${_ble_complete_cand_varnames[@]/%/=}" # #D1570 WA checked
local filter_type pack "${_ble_complete_cand_varnames[@]/%/=}" # WA #D1570 checked
for filter_type in head substr hsubseq subseq; do
ble/path#remove-glob comp_type '[maA]'
case $filter_type in
Expand Down Expand Up @@ -8053,7 +8053,7 @@ function ble/complete/sabbrev/expand {
local -a COMPREPLY=()
builtin eval -- "$value"

local cand action=word "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local cand action=word "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize "$action"
for cand in "${COMPREPLY[@]}"; do
ble/complete/cand/yield "$action" "$cand" ""
Expand Down Expand Up @@ -8110,7 +8110,7 @@ function ble/complete/source:sabbrev {
local comp_filter_type
local comp_filter_pattern
ble/complete/candidates/filter#init "$filter_type" "$COMPS"
local cand action=sabbrev "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local cand action=sabbrev "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize "$action"
for cand in "${keys[@]}"; do
ble/complete/candidates/filter#test "$cand" || continue
Expand Down Expand Up @@ -8437,14 +8437,14 @@ function ble/cmdinfo/complete:cd/.impl {
case $type in
(pushd)
if [[ $COMPV == - || $COMPV == -n ]]; then
local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize "$action"
ble/complete/cand/yield "$action" -n
fi ;;
(*)
COMP_PREFIX=$COMPV
local -a list=()
local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 safe
local "${_ble_complete_yield_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/yield.initialize "$action"
[[ $COMPV == -* ]] && ble/complete/cand/yield "$action" "${COMPV}"
[[ $COMPV != *L* ]] && ble/complete/cand/yield "$action" "${COMPV}L"
Expand Down
2 changes: 1 addition & 1 deletion lib/core-syntax.sh
Expand Up @@ -4418,7 +4418,7 @@ function ble/syntax:bash/ctx-heredoc-word/remove-quotes {
local str=${BASH_REMATCH[1]}
local a b
b='\`' a='`'; str=${str//"$b"/"$a"}
b='\"' a='"'; str=${str//"$b"/"$a"} # WA #D1751 safe
b='\"' a='"'; str=${str//"$b"/"$a"} # WA #D1751 checked
b='\$' a='$'; str=${str//"$b"/"$a"}
b='\\' a='\'; str=${str//"$b"/"$a"}
result=$result$str
Expand Down
17 changes: 9 additions & 8 deletions lib/test-util.sh
Expand Up @@ -1483,7 +1483,7 @@ ble/test ble/util/is-running-in-subshell exit=1

ble/test '[[ ! ${vn+set} ]]'
for name in v1 v{2..8}{a,b}; do
ble/test "declare -p $name x$name | cat -A >&2; [[ \$$name == \$x$name ]]"
ble/test "declare -p $name x$name | cat -v >&2; [[ \$$name == \$x$name ]]"
done

function status { eval 'ret="${#'$1'[*]}:(""${'$1'[*]}"")"'; }
Expand Down Expand Up @@ -1585,13 +1585,14 @@ ble/util/msleep/.calibrate-loop &>/dev/null

# ble/util/cat
(
ble/test ":| ble/util/cat | cat -A" stdout=
ble/test "printf a | ble/util/cat | cat -A" stdout=a
ble/test "printf '\0' | ble/util/cat | cat -A" stdout=^@
ble/test "printf 'hello\nworld\n'| ble/util/cat | cat -A" stdout={hello\$,world\$}
ble/test "printf 'hello\nworld'| ble/util/cat | cat -A" stdout={hello\$,world}
ble/test "printf 'hello\0world\0'| ble/util/cat | cat -A" stdout=hello^@world^@
ble/test "printf 'hello\0world'| ble/util/cat | cat -A" stdout=hello^@world
function ble/test:ble/util/cat { { ble/util/cat; echo x; } | cat -v; }
ble/test ":| ble/test:ble/util/cat" stdout=x
ble/test "printf a | ble/test:ble/util/cat" stdout=ax
ble/test "printf '\0' | ble/test:ble/util/cat" stdout=^@x
ble/test "printf 'hello\nworld\n'| ble/test:ble/util/cat" stdout={hello,world,x}
ble/test "printf 'hello\nworld'| ble/test:ble/util/cat" stdout={hello,worldx}
ble/test "printf 'hello\0world\0'| ble/test:ble/util/cat" stdout=hello^@world^@x
ble/test "printf 'hello\0world'| ble/test:ble/util/cat" stdout=hello^@worldx
)

# ble/util/get-pager
Expand Down
3 changes: 3 additions & 0 deletions make_command.sh
Expand Up @@ -1324,6 +1324,7 @@ function sub:scan {
\Zunset _ble_init_(version|arg|exit|command)\bZd
\Zreadonly -f unsetZd
\Zunset -f builtinZd
\Z'\''\(unset\)'\''Zd
g'
sub:scan/builtin 'unalias' |
sed -E 'h;s/'"$esc"'//g;s/^[^:]*:[0-9]+:[[:space:]]*//
Expand All @@ -1339,6 +1340,7 @@ function sub:scan {
\Zlocal trap$Zd
\Z\$\{content#"trap -- '\''"\}Zd
\Z\("trap -- '\''.*"\*\)Zd
\Z# EXIT trapZd
g'

sub:scan/a.txt
Expand All @@ -1355,6 +1357,7 @@ function sub:scan {
\Zbuiltins1=\(.* unset .*\)Zd
\Zfunction unsetZd
\Zreadonly -f unsetZd
\Z'\''\(unset\)'\''Zd
g'
sub:scan/eval-literal
sub:scan/WA-localvar_inherit
Expand Down

0 comments on commit bb3e0a3

Please sign in to comment.