diff --git a/lib/core-syntax.sh b/lib/core-syntax.sh index a7a65e53..9fcb613f 100644 --- a/lib/core-syntax.sh +++ b/lib/core-syntax.sh @@ -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')?$' } @@ -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]+)?$' @@ -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] diff --git a/memo/ChangeLog.md b/memo/ChangeLog.md index ab3a23fa..9b2fcb9b 100644 --- a/memo/ChangeLog.md +++ b/memo/ChangeLog.md @@ -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 diff --git a/note.txt b/note.txt index 9d7d6d4f..8e9b313c 100644 --- a/note.txt +++ b/note.txt @@ -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