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

Feature request: per-source check-sourced directive #2956

Open
1 of 4 tasks
ShamrockLee opened this issue Mar 28, 2024 · 0 comments
Open
1 of 4 tasks

Feature request: per-source check-sourced directive #2956

ShamrockLee opened this issue Mar 28, 2024 · 0 comments

Comments

@ShamrockLee
Copy link

ShamrockLee commented Mar 28, 2024

For bugs

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/usr/bin/env bash

# I don't want to check this one.
# shellcheck check-sourced=false
source messy.sh 

# I would like to have this checked.
# shellcheck check-sourced=true
source clean.sh

# The rest of the script goes here
echo "Hello, world!"

Here's what shellcheck currently says:

ShellCheck currently doesn't provide such directive.


In temp.sh line 4:
# shellcheck check-sourced=false
             ^-- SC1107 (warning): This directive is unknown. It will be ignored

In temp.sh line 8:
# shellcheck check-sourced=true
             ^-- SC1107 (warning): This directive is unknown. It will be ignored

Here's what I wanted or expected to see:

ShellCheck includes warning from clean.sh but not from messy.sh.

Motivation:

  1. Developers sometimes want to include warnings from some sourced files but not from others. This is especially valid if messy.sh cannot be changed from the project scope.
  2. This feature provide a workaround for Support for pre-declared "external" globals for sourced scripts to avoid SC2154 warnings. #356, by allowing developers to define a meta-script that sources the pre-sourced files before sourcing the target script to check. The directive proposed here helps exclude warnings from pre-sourced files, while include warnings from the target script.
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

1 participant