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

SC1071 should not get checked if -s is specified #974

Closed
blueyed opened this issue Aug 16, 2017 · 6 comments
Closed

SC1071 should not get checked if -s is specified #974

blueyed opened this issue Aug 16, 2017 · 6 comments

Comments

@blueyed
Copy link
Contributor

blueyed commented Aug 16, 2017

For bugs

  • Rule Id (if any, e.g. SC1000): SC1071
  • My shellcheck version (shellcheck --version or "online"): 0.4.6

shellcheck -s sh should use the "sh" dialect, and not look at the shebang line, possibly causing SC1071:

% shellcheck -s sh =(echo '#!/bin/zsh')

In /tmp/zshLclZZ0 line 1:
#!/bin/zsh
^-- SC1071: ShellCheck only supports sh/bash/dash/ksh scripts. Sorry!
@blueyed
Copy link
Contributor Author

blueyed commented Jul 16, 2018

Just came across this again.

Any feedback on this?
Might make it a bit faster even when the shebang parsing would be skipped.

My use case is running it for zsh scripts occasionally.

I could like with a warning, but you could assume that if --shell is specified, this one should be just used.

@blueyed
Copy link
Contributor Author

blueyed commented Jul 16, 2018

Related docs: https://github.com/koalaman/shellcheck/blame/10edba3ab82d58fb262a6ab3cc0245c0e6372259/shellcheck.1.md#L59-L63

The workaround would be for me to remove the shebang before calling shellcheck on it, but I would really like to avoid that.

I think the following needs to be skipped in case the shell option is given, but I do not know how:

sb <- option "" readShebang
verifyShell pos (getShell sb)
if isValidShell (getShell sb) /= Just False

@koalaman
Copy link
Owner

It's probably of very limited use given that basically any syntax that requires #!/bin/zsh also makes shellcheck useless, but I definitely agree that this behavior directly contradicts the purpose of the -s flag.

As of 5005dc0, -s will indeed override this check, and further you can specify the shell override as a directive. This now parses without errors:

#!/bin/zsh
# shellcheck shell=sh
echo "hello world"

@blueyed
Copy link
Contributor Author

blueyed commented Jul 23, 2018

Awesome, thanks!

btw: is there any chance to get back support for Zsh?
What has been the reason to drop it in the first place?
I've only found ed56a83 with no explanations.

@koalaman
Copy link
Owner

You can follow the progress (or lack thereof) on #809.

@blueyed
Copy link
Contributor Author

blueyed commented Jul 28, 2018

Thanks!

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

No branches or pull requests

2 participants