Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unterminated template literal, if first line ends slashed #15704

Closed
tmarshall opened this issue Sep 30, 2017 · 4 comments
Closed

Unterminated template literal, if first line ends slashed #15704

tmarshall opened this issue Sep 30, 2017 · 4 comments
Assignees
Labels
repl Issues and PRs related to the REPL subsystem.

Comments

@tmarshall
Copy link

  • Version: 6.11.3 & 6.10.3
  • Platform: Darwin Kernel Version 16.5.0

I have a small script that templatizes a docker RUN command.

const fileContent = `RUN \\
  cd /tmp && \\
  curl -o ./Python-${version}.tgz https://www.python.org/ftp/python/${version}/Python-${version}.tgz && \\
  tar -xzf ./Python-${version}.tgz && \\
  cd ./Python-${version} && \\
  ./configure && \\
  make && \\
  make install && \\
  cd /tmp && \\
  rm -rf ./Python-${version};
`;

This fails giving:

onst fileContent = `RUN \\
const fileContent = `RUN \\
                    ^^^^^^^

SyntaxError: Unterminated template literal

If I change it to the following, it works:

const fileContent = `#comment

RUN \\
  cd /tmp && \\
  curl -o ./Python-${version}.tgz https://www.python.org/ftp/python/${version}/Python-${version}.tgz && \\
  tar -xzf ./Python-${version}.tgz && \\
  cd ./Python-${version} && \\
  ./configure && \\
  make && \\
  make install && \\
  cd /tmp && \\
  rm -rf ./Python-${version};
`;

Using NVM and switching to 8.6.0 does resolve the issue.

@mscdex mscdex added v6.x v8 engine Issues and PRs related to the V8 dependency. labels Oct 1, 2017
@mscdex
Copy link
Contributor

mscdex commented Oct 1, 2017

I can't reproduce this. I saved this to a file and executed it with node v6.11.3 without any problem:

const version = '2.7';
const fileContent = `RUN \\
  cd /tmp && \\
  curl -o ./Python-${version}.tgz https://www.python.org/ftp/python/${version}/Python-${version}.tgz && \\
  tar -xzf ./Python-${version}.tgz && \\
  cd ./Python-${version} && \\
  ./configure && \\
  make && \\
  make install && \\
  cd /tmp && \\
  rm -rf ./Python-${version};
`;

@mscdex mscdex added question Issues that look for answers. and removed v6.x v8 engine Issues and PRs related to the V8 dependency. labels Oct 1, 2017
@tmarshall
Copy link
Author

tmarshall commented Oct 1, 2017

Ah, so maybe it's only from terminal. I was testing in terminal before executing the full script.

Timothys-MBP:git-container mars$ node
> const version = '2.7';
undefined
> const fileContent = `RUN \\
const fileContent = `RUN \\
                    ^^^^^^^
SyntaxError: Unterminated template literal

>   cd /tmp && \\
  cd /tmp && \\
             ^
SyntaxError: Invalid or unexpected token

>   curl -o ./Python-${version}.tgz https://www.python.org/ftp/python/${version}/Python-${version}.tgz && \\
curl -o ./Python-${version}.tgz https://www.python.org/ftp/python/${version}/Python-${version}.tgz && \\
         ^
SyntaxError: Unexpected token /

>   tar -xzf ./Python-${version}.tgz && \\
tar -xzf ./Python-${version}.tgz && \\
          ^
SyntaxError: Unexpected token /

>   cd ./Python-${version} && \\
cd ./Python-${version} && \\
    ^
SyntaxError: Unexpected token /

>   ./configure && \\
Invalid REPL keyword
>   make && \\
make && \\
        ^
SyntaxError: Invalid or unexpected token

>   make install && \\
make install && \\
     ^^^^^^^
SyntaxError: Unexpected identifier

>   cd /tmp && \\
cd /tmp && \\
           ^
SyntaxError: Invalid or unexpected token

>   rm -rf ./Python-${version};
... `;
... 
> 
(To exit, press ^C again or type .exit)
> 
Timothys-MBP:git-container mars$ node --version
v6.10.3
Timothys-MBP:git-container mars$ 

@tmarshall
Copy link
Author

^ also, i was pasting it, if that makes a difference. In v8 it is fine.

@mscdex mscdex added repl Issues and PRs related to the REPL subsystem. and removed question Issues that look for answers. labels Oct 1, 2017
MylesBorins pushed a commit that referenced this issue Nov 14, 2017
Move the core logic from `LineParser` should fail handling into the
recoverable error check for the REPL default eval.

Fixes: #15704
Backport-PR-URL: #15773
PR-URL: #6171
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
@lance lance self-assigned this Nov 20, 2017
@apapirovski
Copy link
Member

It seems unlikely this will get fixed at this point given that the only viable fix was breaking other packages in the ecosystem. I'm going to close this out but if anyone feels strongly about it, feel free to reopen. Also worth noting that v6.x goes into maintenance at the end of April and this is a very low priority issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants