Skip to content

Commit

Permalink
highlight: fix a bug that arrays without the element "0" is not highl…
Browse files Browse the repository at this point in the history
…ighted
  • Loading branch information
akinomyoga committed Dec 30, 2021
1 parent a41279e commit b0a0b6f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 9 deletions.
5 changes: 3 additions & 2 deletions docs/ChangeLog.md
Expand Up @@ -151,7 +151,7 @@
- mandb: carry optarg for e.g. `-a, --accept=LIST` `#D1687` 23d5657
- mandb: parse `--help` for specified commands `#D1693` e1ad2f1
- mandb: fix small issues of man-page analysis `#D1708` caa77bc
- mandb: insert a comma in brace expansions instead of a space `#D1719` 0000000
- mandb: insert a comma in brace expansions instead of a space `#D1719` 0ac7f03
- edit: work around the wrong job information of Bash in trap handlers (reported by 3ximus) `#D1435` `#D1436` bc4735e
- edit (command-help): work around the Bash bug that tempenv vanishes with `builtin eval` `#D1438` 8379d4a
- global: suppress missing locale errors (reported by 3ximus) `#D1440` 4d3c595
Expand Down Expand Up @@ -212,6 +212,7 @@
- main: fix the message of owner errors of cache directories (reported by zim0369) `#D1712` b547a41
- util (`ble/string#escape-for-bash-specialchars`): fix escaping of TAB `#D1713` 7db3d2b
- complete: fix failglob messages while progcomp for commands containing globchars `#D1716` e26a3a8
- highlight: fix a bug that arrays without the element `0` is not highlighted `#D1721` 0000000

## Documentation

Expand All @@ -238,7 +239,7 @@
- prompt: use `${PS1@P}` when the prompt contains only safe prompt sequences `#D1617` 8b5da08
- prompt: fix not properly set `$?` in `${PS1@P}` evaluation (reported by nihilismus) `#D1644` 521aff9
- decode: cache `inputrc` translations `#D1652` 994e2a5
- complete: use `awk` for batch `quote-insert` (motivated by banoris) `#D1714` a0b2ad2 0000000
- complete: use `awk` for batch `quote-insert` (motivated by banoris) `#D1714` a0b2ad2 92d9734

## Compatibility

Expand Down
9 changes: 5 additions & 4 deletions lib/core-syntax.sh
Expand Up @@ -1850,11 +1850,12 @@ function ble/syntax/highlight/vartype {
fi

local name=$1 opts=$2 tail=$3 rex='^-?[0-9]+(#[0-9a-zA-Z@_]*)?$'
if [[ ${!name+set} ]]; then
local attr; ble/variable#get-attr "$name"
if [[ ${!name} && :$opts: == *:expr:* && ! ( ${!name} =~ $rex ) ]]; then
local attr; ble/variable#get-attr "$name"
if [[ ${!name+set} || $attr == *[aA]* ]]; then
if [[ ${!name-} && :$opts: == *:expr:* && ! ( ${!name} =~ $rex ) ]]; then
ret=$ATTR_VAR_EXPR
elif [[ $attr == *x* ]]; then
elif [[ ${!name+set} && $attr == *x* ]]; then
# Note: 配列の場合には第0要素が設定されている時のみ。
ret=$ATTR_VAR_EXPORT
elif [[ $attr == *a* ]]; then
ret=$ATTR_VAR_ARRAY
Expand Down
56 changes: 53 additions & 3 deletions note.txt
Expand Up @@ -1285,9 +1285,28 @@ bash_tips

2021-12-11

* bash-completion: curl --http0, --http1, --proxy1 等存在しないオプションが生成されている
* bash-completion: printf -v varname
* bash-completion: test, [ の引数の文法に従った補完
* bash-completion

2021-12-22

* fixed: man の中で _expand を呼び出しているが意味ないのでは? info も同様。

* man の _expand の直後にある eval は危ない気がする。
→これは別項目で議論する。

info にも同様の問題が存在する。

* grc '&& [^[:space:]]+ \|\|'
→何故 SC2015 で検出されないのだろうか? 変数代入の場合には許されるのだろうか。

* command ls $... となっている部分が幾つかある。 -- を付加するべき。
他にも色々とあるのではないかと思われる。

2021-12-11

* curl --http0, --http1, --proxy1 等存在しないオプションが生成されている
* printf -v varname
* test, [ の引数の文法に従った補完

2021-12-08

Expand Down Expand Up @@ -1633,6 +1652,16 @@ bash_tips
ToDo
-------------------------------------------------------------------------------

2021-12-22

* ディレクトリ固有の local commands & aliases を可能にする?

一方で、勝手に設定をロードする様にしてしまうと怪しいディレクトリに入っただ
けでそれが有効になってしまうという事が発生する。なので、一旦は enable する
操作を求めるべきだし、また内容が変更されたらその都度承認を求めるべきである
(過去に承認したものは hash か或いは実体を記録しておいて再度尋ねはしない様に
できる)。

2021-12-20

* README: oh-my-bash は流石に削除するべきだろう。
Expand Down Expand Up @@ -5725,6 +5754,27 @@ bash_tips

2021-12-30

* 2021-12-22 highlight: 0 番目の要素の入っていない配列名の着色 [#D1721]

直した。複数の属性がある時にどの着色にするのかというのは悩ましい所だが、そ
れは今迄の実装でも同様であったので今迄の実装を踏襲する。

? 着色を合成するという可能性

x 本当は着色を合成するという手もあるのかもしれないが、合成規則や優先順位
を考えるのは面倒だし、結局どれかの属性は他の属性に上書きされるので意味
がない気がする。

o とは言えど、配列 (既定で太字) に関しては他と組み合わせても問題ない筈で
ある様にも思う。

x と思って対応しようとしたがどうも変数の着色は部分的に構文解析レベルで着
色しているのでその場で生成した描画属性で着色する訳には行かない。

x 更に太字は他にも x や luc にも付与している。array/dict の区別に色を使っ
ている。などという事を考えると (太字かどうか) + (色) を使って配列かどう
かと値の性質の両方を表そうというのは無理がある様に思われる。

* readlink 対策: NixOS で皆が readlink 周りに修正を入れている [#D1720]
https://github.com/peterzky/peterzky-overlay/commit/7b98f05e9b8f84f2d43d84db6b2d76c8e93a38df#diff-34e5f3d20be258f6630e6113d3e1409be74cae463b58eb52b5ebe493e9ee2309R20

Expand Down

0 comments on commit b0a0b6f

Please sign in to comment.