Strange bash syntax highlighting with C-like for loops and subshells

16 views
Skip to first unread message

André Chalella

unread,
Jun 16, 2023, 4:23:45 AM6/16/23
to v...@vim.org
Hi,

I have been using vim a lot for programming bash and quite often
syntax highlighting shows some strange behavior when C-like for loops
and/or subshells are involved.

Please see the small image attached.

It seems to me that in the image the first two examples are fine, but
the third one shows a couple strange things:

Line 12: the "for" line itself is in a different color than when it's
not in a subshell (line 7)
Line 15: the closing parenthesis is in red, as if there was a nesting
mistake or something

I don't have other examples to give right now, but I hope this one
helps shed some light on the root cause.

Other info:

vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 18 2023 11:40:57)

head /usr/share/vim/vim82/syntax/sh.vim
" Vim syntax file
" Language: shell (sh) Korn shell (ksh) bash (sh)
" Maintainer: Charles E. Campbell <Ncamp...@SdrPchip.AorgM-NOSPAM>
" Previous Maintainer: Lennart Schultz <Lennart...@ecmwf.int>
" Last Change: Oct 26, 2021
" Version: 199
" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH
" For options and settings, please use: :help ft-sh-syntax
" This file includes many ideas from Eric Brunet (eric....@ens.fr)
and heredoc fixes from Felipe Contreras

Thanks in advance,
André Chalella
vim_bash_for.png
Reply all
Reply to author
Forward
0 new messages