anordal / shellharden

The corrective bash syntax highlighter
Mozilla Public License 2.0
4.63k stars 130 forks source link

`case` pattern throws error #56

Closed LucasLarson closed 1 year ago

LucasLarson commented 1 year ago

with the following minimal[^1] reproducible example:

$ cat file.sh
case $PATH in
:"$(dirname foo)")
esac
$ shellharden file.sh
file.sh: Unexpected end of file
The file's end was reached without closing all sytactic scopes.
Either, the parser got lost, or the file is truncated or malformed.
$ echo $?
1

[^1]: Less minimally, I found this while creating a case to ensure *:/usr/local/share/"$(command basename -- "${SHELL%%[0-9-]*}")"/site-functions:* was in ":${FPATH-}:"

anordal commented 1 year ago

Thanks for the report!

That was a nice little reproducer. I added a test that elaborates on the quotes and parentheses a bit.

Fixed in commit 08e82a7.

LucasLarson commented 1 year ago

Wow – amazing work, blazingly fast. Thank you!