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

Ignore zsh files in shellcheck #689

Closed
remcohaszing opened this issue Jan 23, 2023 · 7 comments · Fixed by #694
Closed

Ignore zsh files in shellcheck #689

remcohaszing opened this issue Jan 23, 2023 · 7 comments · Fixed by #694
Labels
bug Something isn't working priority ⭐️ Triaged and deemed a priority

Comments

@remcohaszing
Copy link

Code editor

Visual Studio Code

Platform

Linux

Version

v1.29.0

What steps will reproduce the bug?

Open .zshrc or a file with the .zsh extension

How often does it reproduce? Is there a required condition?

The language is configured as Shell Script (shellscript). This is default behaviour in VSCode.

What is the expected behavior?

Nothing

What do you see instead?

It’s checked by Shellcheck, which can’t handle ZSH syntax. This results in a lot of errors.

Additional information

The solution would be to ignore validation of .zshrc and *.zsh files.

@skovhus
Copy link
Collaborator

skovhus commented Jan 24, 2023

That is a really good point. We could also use the shebang, which we are currently parsing.

Note that the treesitter parser we are using isn't really supporting zsh either. #252

Let me know if you want to help out fixing this issue.

@skovhus skovhus added bug Something isn't working priority ⭐️ Triaged and deemed a priority labels Jan 24, 2023
@skovhus
Copy link
Collaborator

skovhus commented Jan 25, 2023

Thanks for the detailed report! That does make a lot of sense. A fix should be out within the next hour.

Let us know if you have other suggestions.

@remcohaszing
Copy link
Author

Thank you!

@lodagro
Copy link

lodagro commented Mar 8, 2023

Using vscode 1.75.0 on linux with Bash IDE 1.35.0, this problem can be reproduced.

foo.zsh

#!/usr/bin/env zsh
source somestuff

This triggers the bash-language-server into showing a problem on the source statement.

Source command could not be analyzed: failed to resolve path.

Consider adding a ShellCheck directive above this line to fix or ignore this:
# shellcheck source=/my-file.sh # specify the file to source
# shellcheck source-path=my_script_folder # specify the folder to search in
# shellcheck source=/dev/null # to ignore the error bash-language-server

The Bash IDE glob pattern i have is the default one:

**/*@(.sh|.inc|.bash|.command)

@skovhus
Copy link
Collaborator

skovhus commented Mar 8, 2023

The error here has nothing to do with shellcheck, but is caused by us not being able to follow the source command. But we do use the shellcheck directive to guide us understanding the source command.

I understand that this can be confusing. Any idea on how to improve this? If we remove the diagnostic/error, then the user might not understand why jump to definition, documentation etc doesn’t work across the sourced file.

@lodagro
Copy link

lodagro commented Mar 8, 2023

If this message would show up in a bash script, that would be fine (although i thought that shellcheck did run).

It is my understanding zsh scripts are not supported by the Bash IDE, so i do not expect it to run at all. I took the source only as an example to show the Bash IDE is running on a script where i do not expect the Bash IDE to run on.

@skovhus
Copy link
Collaborator

skovhus commented Mar 8, 2023

It is my understanding zsh scripts are not supported by the Bash IDE

well the support is not great, but it does a decent job for a lot of simpler zsh scripts. But we could disable this specific error for zsh files. Note that the language server is called for any 🐚-scripts and we just try to be helpful in return.

Official zsh support is covered in #252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority ⭐️ Triaged and deemed a priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants