textmate / shellscript.tmbundle

TextMate support for ShellScript
43 stars 29 forks source link

Here strings (`<<<`) cause syntax highlight issues with command substitution #51

Closed dnicolson closed 2 years ago

dnicolson commented 2 years ago

Here strings (<<<) when used with command substitution cause two issues:

#!/bin/bash

echo one two
cat <<< $(echo one two)
echo one two

echo one two
cat <<< `echo one two`
echo one two

echo one two
cat <<< $(echo one two)
echo one two
Screenshot 2022-09-10 at 20 10 09
mkhl commented 2 years ago

nice catch! currently after the here string operator we only recognize either rather simple strings or barewords so i expect the grammar to also fail for sufficiently complicated variable substitutions. it might make more sense to drop those rules altogether, i.e. recognize the <<< but let the regular shell grammar take back over immediately after, since we can't reliably detect where the actual here string ends :thinking:

my availability is kind of limited right now, would you consider submitting a pr?

for completeness' sake i should point out that here strings with command substitutions don't make a lot of semantic sense since foo <<<$(bar) is equivalent to bar | foo, and that you should generally quote command substitutions (although bash doesn't seem to apply word splitting here :shrug:), but that's not what this issue is about :vulcan_salute:

dnicolson commented 2 years ago

I guess I could try a bit later, I don't have experience with .tmLanguage files so it's not immediately obvious to me where to make the changes.

mkhl commented 2 years ago

i found some time to do it, could you check if cd4cf53 works for you?

dnicolson commented 2 years ago

It works, thanks for the quick fix!