Skip to content

Commit

Permalink
syntax (ble/syntax:bash/simple-word/evaluate-path-spec): fix unrecogn…
Browse files Browse the repository at this point in the history
…ized "[!...]"
  • Loading branch information
akinomyoga committed Nov 6, 2020
1 parent 6fd9e22 commit 0b842f5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/core-syntax.sh
Expand Up @@ -1094,8 +1094,8 @@ function ble/syntax:bash/simple-word/update {

# @var _ble_syntax_bash_simple_rex_incomplete_word1
# @var _ble_syntax_bash_simple_rex_incomplete_word2
local letter1='[^{'${_ble_syntax_bashc_simple}']'
local letter2='[^'${_ble_syntax_bashc_simple}']'
local letter1='\[[!^]|[^{'${_ble_syntax_bashc_simple}']'
local letter2='\[[!^]|[^'${_ble_syntax_bashc_simple}']'
_ble_syntax_bash_simple_rex_incomplete_word1='^('$bquot'|'$squot'|'$dquot'|'$param'|'$letter1')+'
_ble_syntax_bash_simple_rex_incomplete_word2='^(('$bquot'|'$squot'|'$dquot'|'$param'|'$letter2')*)(\\|'$open_squot'|'$open_dquot')?$'
}
Expand All @@ -1122,7 +1122,7 @@ function ble/syntax:bash/simple-word/evaluate-last-brace-expansion {
local squot=$_ble_syntax_bash_simple_rex_squot
local dquot=$_ble_syntax_bash_simple_rex_dquot
local param=$_ble_syntax_bash_simple_rex_param
local letter='[^{,}'${_ble_syntax_bashc_simple}']'
local letter='\[[!^]|[^{,}'${_ble_syntax_bashc_simple}']'
local symbol='[{,}]'

local rex_range_expansion='^(([-+]?[0-9]+)\.\.\.[-+]?[0-9]+|([a-zA-Z])\.\.[a-zA-Z])(\.\.[-+]?[0-9]+)?$'
Expand Down Expand Up @@ -1373,7 +1373,7 @@ function ble/syntax:bash/simple-word/.get-rex_element {
local bquot=$_ble_syntax_bash_simple_rex_bquot
local squot=$_ble_syntax_bash_simple_rex_squot
local dquot=$_ble_syntax_bash_simple_rex_dquot
local letter1='[^'$sep$_ble_syntax_bashc_simple']'
local letter1='\[[!^]|[^'$sep$_ble_syntax_bashc_simple']'
rex_element='('$bquot'|'$squot'|'$dquot'|'$param'|'$letter1')+'
}
## 関数 ble/syntax:bash/simple-word/evaluate-path-spec path_spec [sep] [opts]
Expand Down
1 change: 1 addition & 0 deletions memo/ChangeLog.md
Expand Up @@ -136,6 +136,7 @@
- prompt: fix extra spaces on line folding before double width character `#D1400` d84bcd8
- prompt: fix a bug that lonig rps1 is not correctly turned off `#D1401` d84bcd8
- syntax (glob bracket expression): fix a bug of unsupported POSIX brackets `#D1402` 0000000
- syntax (`ble/syntax:bash/simple-word/evaluate-path-spec`): fix a bug of unrecognized `[!...]` and `[^...]` `#D1403` 0000000

## Compatibility

Expand Down
21 changes: 21 additions & 0 deletions note.txt
Expand Up @@ -3561,6 +3561,27 @@ bash_tips

2020-11-06

* syntax: [!...] が常にエラー着色になっている問題 [#D1403]

うーん。これは ble/syntax:bash/simple-word/is-simple が成功しているのに、
ble/syntax:bash/simple-word/evaluate-path-spec が失敗しているのが行けない。
正規表現の構築で ! を含めるのを忘れているという事だろうか。

is-simple で使っている正規表現は以下の通り。
local letter='\[[!^]|[^'${_ble_syntax_bashc_simple}']'
_ble_syntax_bash_simple_rex_element='('$bquot'|'$squot'|'$dquot'|'$param'|'$letter')'
_ble_syntax_bash_simple_rex_word='^'$_ble_syntax_bash_simple_rex_element'+$'

evaluate-path-spec で使っている正規表現は以下の通り。
local letter1='[^'$sep$_ble_syntax_bashc_simple']'
rex_element='('$bquot'|'$squot'|'$dquot'|'$param'|'$letter1')+'

あー。分かった。letter で特別扱いしている物を入れるのを忘れている。

他にも同様の違いがある物が色々ある。これは #D1303 の cmplstofB さんの報告が
あった時の修正で中途半端な修正になっていたのが原因。合わせて関連する letter
の正規表現も一括して修正する。

* syntax: glob bracket expression で POSIX [...] に対応していない (reported by alvinseville7cf) [#D1402]
https://github.com/akinomyoga/ble.sh/issues/66

Expand Down

0 comments on commit 0b842f5

Please sign in to comment.