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

SC2317 false positives on scripts run with source and having return as its last command #3046

Open
1 of 4 tasks
pteroismw opened this issue Aug 27, 2024 · 0 comments
Open
1 of 4 tasks

Comments

@pteroismw
Copy link

For bugs

For new checks and feature suggestions

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

main.sh

#!/bin/bash
# shellcheck source=./sourced.sh
source sourced.sh
echo "this comes after 'source sourced.sh'"
echo "the next line"

sourced.sh

return

Here's what shellcheck currently says:

> shellcheck -x main.sh

In main.sh line 4:
echo "this comes after 'source sourced.sh'"
^-- SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).

In main.sh line 5:
echo "the next line"
^------------------^ SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).

For more information:
  https://www.shellcheck.net/wiki/SC2317 -- Command appears to be unreachable...

All lines following source ... are reported as unreachable.

Here's what I wanted or expected to see:

The highlighted commands are reachable and should not be flagged.

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