Skip to content

Commit

Permalink
syntax: adjust context after ((...)) and [[ ... ]] in bash-5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Feb 19, 2023
1 parent bb8541d commit 67cb967
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Expand Up @@ -122,6 +122,7 @@
- util (`ble/builtin/trap`): support Bash 5.2 `trap -P` `#D1937` 826a275
- syntax: highlight `\?` in here documents `#D1959` xxxxxxx
- syntax: recognize history expansion in here documents, `"...!"` (bash <= 4.2), and `$!` (bash <= 4.1) `#D1959` xxxxxxx
- syntax: support context after `((...))` and `[[ ... ]]` in bash-5.2 `#D1962` xxxxxxx

## Changes

Expand Down
4 changes: 2 additions & 2 deletions lib/core-syntax.sh
Expand Up @@ -3584,7 +3584,7 @@ function ble/syntax:bash/ctx-command/check-word-end {
# 条件コマンド開始
ble/syntax/parse/touch-updated-attr "$wbeg"
((_ble_syntax_attr[wbeg]=ATTR_DEL,
ctx=CTX_ARGX0))
ctx=_ble_bash>=50200?CTX_CMDXE:CTX_ARGX0))

ble/syntax/parse/word-cancel # 単語 "[[" (とその内部のノード全て) を削除
if [[ $word == '[[' ]]; then
Expand Down Expand Up @@ -3852,7 +3852,7 @@ function ble/syntax:bash/ctx-command/.check-delimiter-or-redirect {
local m=${BASH_REMATCH[0]}
if ((ctx==CTX_CMDX||ctx==CTX_CMDX1||ctx==CTX_CMDXT||ctx==CTX_CMDXC)); then
((_ble_syntax_attr[i]=ATTR_DEL))
((ctx=${#m}==1?CTX_CMDXE:CTX_ARGX0))
((ctx=_ble_bash>=50200||${#m}==1?CTX_CMDXE:CTX_ARGX0))
[[ $_ble_syntax_bash_is_command_form_for && $tail == '(('* ]] && ((ctx=CTX_CMDXD0))
ble/syntax/parse/nest-push "$((${#m}==1?CTX_CMDX1:CTX_EXPR))" "$m"
((i+=${#m}))
Expand Down
10 changes: 6 additions & 4 deletions note.txt
Expand Up @@ -1946,10 +1946,9 @@ bash_tips

* README: Guix package の位置が変わっている。

* syntax: 関数名として function `xxx` 等も実は許されている。
5.3 以降では更に <(...) も関数名として使える。

* syntax: 5.2 以降では (()) [[]] の直後は } 等が来ても良い。
* syntax: 5.0 以降では関数名として function `xxx` 等も実は許されている。5.3
以降では更に <(...) も関数名として使える。しかもこれらは `xxx`() や
<(...)() の形式でも定義できる。

2023-02-06

Expand Down Expand Up @@ -6677,6 +6676,9 @@ bash_tips

2023-02-12

* syntax: 5.2 以降では (()) [[]] の直後は } 等が来ても良い [#D1962]
これの修正は簡単。

* color: ble palette の並び方をより分りやすく (suggested by stackoverflow/caoanan) [#D1961]
https://superuser.com/a/1512656/980046 コメント by caoanan

Expand Down

0 comments on commit 67cb967

Please sign in to comment.