Sublime Forum

Build 4200 new bash syntax issue with reserved-word + backslash + newline + space?

#1

The following 3 successions with the reserved word then seem correclty highlighted but the 4th one doesn’t (then and echo not correctly highlighted although space delimited?):

Screenshot_20250625_073717

Sample lines

# 1 ok
if true; then \
    echo hello
fi
# 2 ok
if true; then \
echo hello
fi
# 3 ok
if true; then\
echo hello
fi

# 4 wrong?
if true; then\
    echo hello
fi

I guess this counts for all of the reserved words (included in and do if they are the third word of respectively case or for and for commands).

if
then
elif
else
fi
time
for
in
until
while
do
done
case
esac
coproc
select
function
{
}
[[
]]
!

Reference for backslash newline: Escape Character section of the bash manual.

0 Likes

#2

Basically Bash and Zsh support line continuation characters everywhere - even in the middle of keywords, like:

if true; the\
n

It is however not feasable or possible to support this level of oddities as ST’s syntax engine parses files in single runs, while bash performs parsing in multiple loops (1. tokenize words, 2. remove quotes 3. handle escapes, …). We can mimic this behavior to some degree and actually push it to the limits already causing Bash being one of the most complex syntaxes in ST world right now, but we won’t be able to catch all those nonsense edge cases.

The way your examples use line continuation is JUST NONSENSE!

1 Like

#3

I know, blame bash.

1 Like