Skip to content

Add a check for checking return code after a local or declare line #643

@thegranddesign

Description

@thegranddesign

Given:

declare foo="$(some_script_that_fails_with_exit_code_200)"

[ $? == 0 ] && echo 'yes'

Will always echo yes because the return code is the code from the declare command and not from the subshell. The proper way to write this would be:

declare foo

foo="$(some_script_that_fails_with_exit_code_200)"

[ $? == 0 ] && echo 'yes'

It would be great if there was a check that could catch this.

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