Parser breaks on more than 2 pipes in a loop
ChillerDragon opened this issue · comments
Chiller Dragon commented
Code editor
neovim
Platform
Unix
Version
5.1.2
What steps will reproduce the bug?
#!/bin/bash
urlencodepipe() {
LANG=C;
while IFS= read -r c;
do
case $c in [a-zA-Z0-9.~_-]) printf "%s" "$c"; continue ;; esac
printf "%s" "$c" | od -An -tx1 | tr ' ' % | tr -d '\n'
done <<EOF
$(fold -w1)
EOF
echo
}
urlencode() {
printf '%s\n' "$*" | urlencodepipe
}
urlencode foo bar
$ cat test.sh
#!/bin/sh
urlencodepipe() {
LANG=C;
while IFS= read -r c;
do
case $c in [a-zA-Z0-9.~_-]) printf "%s" "$c"; continue ;; esac
printf "%s" "$c" | od -An -tx1 | tr ' ' % | tr -d '\n'
done <<EOF
$(fold -w1)
EOF
echo
}
urlencode() {
printf '%s\n' "$*" | urlencodepipe
}
urlencode foo bar
$ shellcheck test.sh
$ sh test.sh
foo%20bar
How often does it reproduce? Is there a required condition?
Every time with this exact code.
What is the expected behavior?
Be robust and do not break the entire file if one syntax is parsed wrong.
Don't fail to parse valid bash scripts.
What do you see instead?
Starting in line 10 it just breaks down. The syntax highlighter for the rest of the file is useless. The documentation comments are gone. It just seems to fully die.
Additional information
I had a bit of a hard time producing a minimal example. This is one with a bit less code that still breaks
Interestingly removing one of the pipes fixes it
So the simplest one I could come up with is this one
#!/bin/bash
hell() {
while read -r word
do
printf "%s" "$word" | cat | cat | cat
done <<EOF
hello world
EOF
}
hell