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

Bash linter doesn't detect whitespace after EOF #234337

Open
Yanni8 opened this issue Nov 21, 2024 · 0 comments
Open

Bash linter doesn't detect whitespace after EOF #234337

Yanni8 opened this issue Nov 21, 2024 · 0 comments
Assignees

Comments

@Yanni8
Copy link

Yanni8 commented Nov 21, 2024

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.95.3
  • OS Version: macOS 14.5

Issue

You can, in bash, read an input stream until a specific delimiter is found. An easy example of this would be:

cat << EOF > hello.txt
Hello World
EOF

The problem with this is that bash only accepts this as a valid delimiter if it matches the pattern ^EOF$.

The problem now is that whitespace at the end marks the delimiter as invalid, which makes bash ignore it.

A script like this would, therefore, not be valid:

cat << EOF > hello.txt
Hello World
EOF 

(Note the only difference here is that the last line is EOF instead of EOF)

Finding such issues is hard, especially if you have another delimiter after this one, like for example:

cat << EOF > hello.txt
Hello
EOF 

cat << EOF > world.txt
World
EOF

(The first EOF has a tailing whitespace at the end the second one doesn't)

This script would create one file called hello.txt which has the following content:

Hello
EOF 

cat << EOF > world.txt
World

The VSCode syntax highlighter ignores the trailing whitespace at the end of the EOF and marks it as a valid delimiter.

Such issues probably only occur in rare edge cases, but it would be nice if VSCode would mark the EOF as not valid, if it has a tailing whitespace, and also display this in the syntax highlighting. Or maybe even better, display a warning to the user that there is a trailing whitespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants