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

Warn when functions that exit are invoked in subshells #1558

Open
2 tasks done
koalaman opened this issue Apr 26, 2019 · 0 comments
Open
2 tasks done

Warn when functions that exit are invoked in subshells #1558

koalaman opened this issue Apr 26, 2019 · 0 comments

Comments

@koalaman
Copy link
Owner

For new checks and feature suggestions

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

Inspired by #1158

#!/bin/sh

my_mktemp() {
  mktemp || exit 42
}

dir=$(my_mktemp)
echo "$dir"

Here's what shellcheck currently says:

Nothing

Here's what I wanted or expected to see:

The exit is buggy here, since the function is only ever called in a subshell so it'll never do anything other than return

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