Skip to content

SC2317 false positive upon: return 1 || exit 1 #3418

@smyril42

Description

@smyril42

For bugs with existing features

  • Rule Id: SC2317
  • My shellcheck version: 0.10.0
  • The rule's wiki page does not already cover this
  • I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit

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

#!/bin/sh
return 1 || exit 1

or

#!/bin/sh
return 1 2>/dev/null || exit 1

Here's what shellcheck currently says:

return 1 || exit 1
            ^-- [SC2317](https://www.shellcheck.net/wiki/SC2317) (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).

Here's what I wanted or expected to see:

This should return 1 if in a function and exit otherwise (when return fails).
It should not raise any warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions