How to match underscores in my variable definition regex?


#1

Hi,

I have this code block for matching variable definitions in shell script in my fork of the core language-shellscript package, language-unix-shell:

      {
        'begin': '(?<![/$/[a-zA-Z0-9_]/|/\\=/\\//])([a-zA-Z0-9_-]+)(\\+=|=)'
        'beginCaptures':
          '1':
            'name': 'variable.definition.name'
          '2':
            'name': 'variable.definition.equal'
        'end':  ';|&|$|'
        'endCaptures':
          '0':
            'name': 'punctuation.definition.function.shell'
      }

the problem is that it fails to match underscores (_) in variable definitions so of this example variable definition:

-DCMAKE_INSTALL_PREFIX=/usr

only -DCMAKE is syntax-highlighted using the variable.definition.name style. For some reason what comes after _ is not given the variable.definition.name style. How do I change this code block in order to get the syntax-highlighting of shell variable definitions right?

Thanks for your time,
Brenton