Skip to content

Commit

Permalink
syntax (glob bracket expression): fix a bug of unsupported POSIX brac…
Browse files Browse the repository at this point in the history
…kets
  • Loading branch information
akinomyoga committed Dec 2, 2020
1 parent 9266961 commit e1eca65
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/core-syntax.sh
Expand Up @@ -1620,8 +1620,14 @@ function ble/syntax:bash/check-glob {
((_ble_syntax_attr[i++]=${force_attr:-CTX_BRAX}))
elif [[ ${text:i:1} == '[' ]]; then
# Note: 条件コマンド [[ に変換する為に [[ の連なりは一度に読み取る。
((_ble_syntax_attr[i++]=${force_attr:-CTX_BRAX}))
[[ ${text:i:1} == '!'* ]] && ((i++))
if [[ ${text:i+1:1} == [:=.] ]]; then
# Note: glob bracket expression が POSIX 括弧で始まっている時は
# [[ が一まとまりになっていると困るので除外。
ble/syntax/parse/set-lookahead 2
else
((_ble_syntax_attr[i++]=${force_attr:-CTX_BRAX}))
[[ ${text:i:1} == '!'* ]] && ((i++))
fi
fi

return 0
Expand Down Expand Up @@ -1894,7 +1900,7 @@ function ble/syntax:bash/ctx-bracket-expression {
# is-delimiters の時に [... は其処で不完全終端する。
local chars=${_ble_syntax_bash_chars[CTX_ARGI]//'~'}
fi
chars="]${chars#']'}"
chars="][${chars#']'}"

local ntype; ble/syntax/parse/nest-type -v ntype
local force_attr=; [[ $ntype == glob_attr=* ]] && force_attr=${ntype#*=}
Expand Down Expand Up @@ -1924,6 +1930,13 @@ function ble/syntax:bash/ctx-bracket-expression {
fi
fi
return 0
elif [[ $tail == '['* ]]; then
rex='^\[@([^'$chars']+(@\]?)?)?'
rex=${rex//@/:}'|'${rex//@/'\.'}'|'${rex//@/=}'|^\['
[[ $tail =~ $rex ]]
((_ble_syntax_attr[i]=${force_attr:-ctx},
i+=${#BASH_REMATCH}))
return 0
elif rex='^([^'$chars']|\\.)+' && [[ $tail =~ $rex ]]; then
((_ble_syntax_attr[i]=${force_attr:-ctx},
i+=${#BASH_REMATCH}))
Expand Down

0 comments on commit e1eca65

Please sign in to comment.