question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SC1041,1042 Cannot Find 'EOF' with Output Redirection on Same Line

See original GitHub issue

OS: Windows 10 Enterprise, Version 1909, Build 18363.1556 VSCode Version: 1.56.2 Shellcheck Version: 0.7.2 (installed from .zip on GitHub)

The following code works on shellcheck.net, but fails in VSCode on Windows:

#! /bin/sh -

my_file_='example.txt'

# Overcoming a strange Cygwin error
command cat <<EOF >"${my_file_}"
#! /bin/sh
exit 0
EOF

This could be fixed by putting >“${my_file_}” before <<EOF, but the bigger issue is VSCode sees ‘EOF\r’ at end (NOTE: This is not fixed by ignoring carriage-return/new-lines errors with # shellcheck disable=SC1017. Furthermore, the above code works on shellcheck.net, so I believe the problem is with the VSCode extension.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
adamgranthendrycommented, May 26, 2021

@felipecrs I wrote the scripts in Cygwin real quick with Vim and they worked (shellcheck returned nothing, which I’m assuming means no errors)

0reactions
felipecrscommented, May 26, 2021

That’s cool to hear, @adamgranthendry. Did you also try to execute your scripts in Cygwin just to confirm that they are still working?

Read more comments on GitHub >

github_iconTop Results From Across the Web

SC1041,1042 Cannot Find 'EOF' with Output Redirection on ...
There is definitely a Windows element to this as it is detecting a newline simply as a carriage return. This specific error can...
Read more >
How do you use output redirection in combination with here ...
When it's evaluating the command-line and finds the <<EOF, it then reads from standard input until either a line with only EOF is...
Read more >
Redirecting stdout of EOF - Stack Overflow
I called gnuplot and not psql , but the idea about EOF and redirecting is the same. Share.
Read more >
How to redirect the output when we are usinf EOF in the same ...
Could somebody help me on how to redirect output of command line and process it line by line without sending output to any...
Read more >
Input Output Redirection in Linux/Unix Examples - Guru99
If there is an existing file with the same name, the redirected command will delete the contents of that file and then it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found