Wednesday, June 14, 2023

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

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 <NcampObell@SdrPchip.AorgM-NOSPAM>
" Previous Maintainer: Lennart Schultz <Lennart.Schultz@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.brunet@ens.fr)
and heredoc fixes from Felipe Contreras

Thanks in advance,
André Chalella

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJzKEg9X7REBqKXYeTENxoVyp5_dDo5zqcKmkw%2Bmq9fmbDtk7A%40mail.gmail.com.

No comments: