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

exec checks fail to see execfail shopt #3178

Closed
1 of 2 tasks
matthewpersico opened this issue Apr 2, 2025 · 1 comment
Closed
1 of 2 tasks

exec checks fail to see execfail shopt #3178

matthewpersico opened this issue Apr 2, 2025 · 1 comment

Comments

@matthewpersico
Copy link

For bugs

  • Rule Id (if any, e.g. SC1000): SC2093
  • My shellcheck version (shellcheck --version or 'online'): online
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit
  • It's not reproducible on shellcheck.net, but I think that's because it's an OS, configuration or encoding issue

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

#!/usr/bin/env bash
shopt -s execfail # allow exec to fail-through
exec command1 "$@"
exec command2 "$@"
echo "Failed to find either 'command1' or 'command2', check installation"
exit 1

Here's what shellcheck currently says:

Line 3	SC2093: Remove "exec " if script should continue after this command.

Here's what I wanted or expected to see:

No such error. execfail is set so the script will continue if the exec on line 3 fails. Given that execfail is set, I think the user understands the consequences. Now, if execfail was not set, then yes, then SC2093 should apply.

@koalaman
Copy link
Owner

koalaman commented Apr 7, 2025

Makes sense. The warning is now suppressed when shopt -s execfail appears anywhere in the script (regardless of context).

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