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

scan_regex too restrictive? #43

Open
4 tasks done
kaihowl opened this issue Dec 4, 2021 · 2 comments
Open
4 tasks done

scan_regex too restrictive? #43

kaihowl opened this issue Dec 4, 2021 · 2 comments

Comments

@kaihowl
Copy link

kaihowl commented Dec 4, 2021

New Issue Checklist

  • Using the latest version of azohra/shell-linter
  • Able to reproduce error multiple times
  • Provided information about the bug
  • Attached additional information about the error including logs

Issue Description

The `scan-regex` with `#!.*[/ ](sh|bash|dash|ksh)$` does not expect valid options in shebang.

Steps to Reproduce

Add a repo with a bash file "test.sh" that start with `#!/bin/bash -e`.

Error Message

ShellCheck only supports sh/bash/dash/ksh scripts. For supported scripts to be scanned, make sure to add a proper shebang on the first line of the script.

Logs

n/a

Link to the GitHub Actions workflow (optional)

n/a
@kaihowl
Copy link
Author

kaihowl commented Dec 5, 2021

Hi,

shellcheck also supports forcing zsh scripts for example to be interpreted as if they are bash script by adding the following after the shebang:

# shellcheck shell=bash

Is that also something that should be supported? Or is it already and I overlooked something in the configuration?

@ThomDietrich
Copy link

ThomDietrich commented Oct 21, 2024

This is an old issue but still relevant. Your project is currently not compliant with: https://www.shellcheck.net/wiki/SC1008

The regex in question is

scan_regex="#!.*[/ ](sh|bash|dash|ksh)$"

Therefore, # shellcheck shell=bash is not supported.

I would suggest to extend the head command to include the second line and support = in the regex.

local first_line=$(head -n 1 "$script")

Would the maintainers accept a PR for this?

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