camdencheek / tree-sitter-dockerfile

A tree-sitter grammar for Dockerfile
MIT License
73 stars 22 forks source link

Trouble with \e sequences in shell strings #56

Open mjambon opened 5 months ago

mjambon commented 5 months ago

I checked that echo "\e[91m" is syntactically valid in both Bash and Bourne shell (although it has a different meaning, see my comment at https://github.com/semgrep/semgrep/issues/10068#issuecomment-2057821081).

It causes a parsing error with tree-sitter-dockerfile:

$ cat escape.dockerfile
RUN echo "\e[91m"

$ tree-sitter parse escape.dockerfile 
(source_file [0, 0] - [1, 0]
  (ERROR [0, 0] - [0, 17]
    (run_instruction [0, 0] - [0, 12]
      (shell_command [0, 4] - [0, 12]
        (shell_fragment [0, 4] - [0, 12])))))
escape.dockerfile   0 ms    (ERROR [0, 0] - [0, 17])