[vim/vim] runtime/syntax/sh.vim: Array highlighting (Issue #20183)

3 views
Skip to first unread message

Dan Church

unread,
May 10, 2026, 1:28:03 PM (23 hours ago) May 10
to vim/vim, Subscribed
h3xx created an issue (vim/vim#20183)

Steps to reproduce

  1. Create a file with the following contents:
#!/bin/bash
array_a=()
array_b=()
if :; then :; fi
  1. Open it in vim with syntax highlighting on :sy on and filetype=sh.

Expected behaviour

array_a=() and array_b=() should be highlighted the same but aren't.

The array_b=() gets highlighted the same as if it were a function declaration, i.e. array_b() { ...; }.

image.png (view on web)

I did a git bisect which let me know it was 12f6f20 that introduced this issue.

Version of Vim

9.2.0433

Environment

Operating System: Slackware Linux
Terminal: PuTTY for Windows
Value of $TERM: screen.xterm-256color
Shell: Bash 5.3

Logs and stack traces


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20183@github.com>

Aliaksei Budavei

unread,
May 10, 2026, 7:18:50 PM (17 hours ago) May 10
to vim/vim, Subscribed
zzzyxwvut left a comment (vim/vim#20183)

Well, = is not a metacharacter etc. in Bash (v5.3.9), and it
appears array_b= is a word, which is within rule 7b.

Try patching your example as follows:

--- 20183.bash
+++ 20183_.bash
@@ -1,4 +1,7 @@
 #!/bin/bash
+set -o posix
 array_a=()
 array_b=()
-if :; then :; fi
+if :; then echo $1; fi
+array_b[0]="$1"
+array_b= ${array_b[0]}

and then run with it:

./20183_.bash ./20183_.bash

I guess we can make such ambiguous recognition configurable
via a global variable, e.g. g:sh_not_in_bash_function_name,
and support a string of arbitrary characters, e.g. ][=, for
its value; and then let users decide what other characters
in their scripts do not belong to function names in addition
to metacharacters already excluded.

Please advise, @dkearns.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20183/4416602649@github.com>

dkearns

unread,
8:14 AM (4 hours ago) 8:14 AM
to vim/vim, Subscribed
dkearns left a comment (vim/vim#20183)

What's the bug here? array_b= is a function in bash going back to at least version 4.4 and is highlighted correctly.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20183/4420562284@github.com>

Reply all
Reply to author
Forward
0 new messages