So I have a BASH script I'm modifying and I've been noticing large blocks of script with broken syntax highlighting. They appear as though I have an unpaired double quote somewhere, despite all quotes in and around the affected lines being properly paired and the script executing perfectly fine in that region. The broken highlighting spans multiple functions, and seems to be related to the escaped quote at the end of the eval local value=\"\${WORLD_$2[$1]}\"
line. The issue occurs in multiple other places in this file, all issue instances seem
I've had this issue appear on both Debian 10 Vim 8.1 and on MacVim 8.2.539 on two different machines.
Here's where the issue first occurs in my code:
...
# Get the value of a world property
# $1: The world ID
# $2: The property name
world_property() {
# Get the current value
eval local value=\"\${WORLD_$2[$1]}\"
### Issue begins after the final end quote of previous line #467
### ...
### multiple function closings and new function openings omitted
### ...
error_exit NAME_NOT_FOUND "Could not find id for world \"$2\" for server \"${SERVER_NAME[$1]}\"."
### Issue stops from end of previous line #614
}
(Triple hashed comments mine)
So, any ideas why these lines would cause the syntax highlighter to invert its interpretation of the opening and closing of quotes at these lines? Alternatively, is there some way I can change the two lines in question to maintain functionality and avoid the issue?
I've uploaded the entire script as a gist so you can see the issue for yourself and play with the file.
'
here, which should fix the issue and is arguably cleaner as well:eval 'local value="${WORLD_$2[$1]}"'
$1
and$2
won't be expanded in single quotes--unlesseval
then evaluates them too?