Sublime Forum

Syntax Highlighting for Bash broken

#1

Hi,

the double quote between the two braces }"} leads to the problem, that the syntax highlighting fails for the rest of the code!

[code]#!/bin/sh

some stuff here…

foobar() {
echo “this is correct”
}

foo “$1” ${bar:+xyz “${bar}”} 2>&1 /dev/null

no correct syntax highlighting anymore…

foobar2() {
echo “this is not correct :(”
}[/code]

Cheers,
tabas

0 Likes

#2

Still have this problem in Sublime 3 Build 3114

${ADD_ARGS+"${ADD_ARGS[@]}"}

It’s the quotes in the {}, probably due to the {} inside of {} not being handled 100% right. Looks like the first } closes the first { rather than the second {

:frowning:

Issue Duplicated here

0 Likes

#3

Note, I was able to make the syntax highlighting work by modifying variable highlighting for the Bash Shell script

  1. Copy the Shell-Unix-Generic.sublime-syntax and unzip

  2. Modify the name: field so you know which one is yours :wink:

  3. Go down to the variable: section, and modify the last push: section to include -include: string like so

     push:
     - meta_scope: variable.other.bracket.shell
     - match: '\}'
       captures:
         0: punctuation.definition.variable.shell
       pop: true
     - include: string
     - match: '!|:[-=?]?|\*|@|#{1,2}|%{1,2}|/'
       scope: keyword.operator.expansion.shell
     - match: '(\[)([^\]]+)(\])'
       captures:
         1: punctuation.section.array.shell
         3: punctuation.section.array.shell
    
  4. Save, and re-zip up into a .sublime-syntax file

  5. Place in your ~/.config/sublime-text-3/Installed Packages/

0 Likes

#4

You may interest in https://packagecontrol.io/packages/ShellScriptImproved.
Or, wond has promised a re-written syntax definition for shellscript.

0 Likes

#5

Thanks @jfcherng! I missed that.

MUCH better :slight_smile:

0 Likes