--syntax sh crashes since 4.17 with shellscript.lang:77: attempt to index upvalue '_ENV' (a nil value)
~Any attempt to highlight shell scripts crashes since 4.17.
To reproduce: `highlight --syntax sh <<< a`
Output of `highlight --fragment --syntax sh <<< a` in 4.16:
a
Output of `highlight --fragment --syntax sh <<< a` in 4.17:
terminate called after throwing an instance of 'Diluculum::LuaRunTimeError'
what(): ...highlight-4.17/share/highlight/langDefs/shellscript.lang:77: attempt to index upvalue '_ENV' (a nil value)
Aborted (core dumped) ./result/bin/highlight --fragment --syntax sh <<< a
Output of `highlight --fragment --syntax sh <<< a` in 4.18:
highlight: ...highlight-4.18/share/highlight/langDefs/shellscript.lang:77: attempt to index upvalue '_ENV' (a nil value)
Output of `highlight --fragment --syntax sh <<< a` 4.19 (HEAD):
highlight: ...highlight-4.19/share/highlight/langDefs/shellscript.lang:77: attempt to index upvalue '_ENV' (a nil value)
Bisecting between 4.16 and 4.17, the problem was introduced in commit c81a8cbfaf0d6e4778015e1fb617def1dcdc5821 "updated some language definitions"
If I remove the "handling for nested command substitution within strings" logic introduced in that change, it stops crashing (verified in 4.17, 4.18, and 4.19(HEAD)). Patch against 4.19(HEAD): [highligh--fix-crash--remove-sh-nested-command-substitution-within-strings-logic.patch](/uploads/e7a96e435889db5fa71f64585e2be271/highligh--fix-crash--remove-sh-nested-command-substitution-within-strings-logic.patch)
issue