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

SC2164 #3003

Open
1 of 2 tasks
zefir-git opened this issue Jun 17, 2024 · 2 comments
Open
1 of 2 tasks

SC2164 #3003

zefir-git opened this issue Jun 17, 2024 · 2 comments

Comments

@zefir-git
Copy link

For bugs

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

#!/bin/zsh
function foo() {
    cd generated_files
    return $?
}

Here's what shellcheck currently says:

SC2164: suggested cd generated_files || exit

Here's what I wanted or expected to see:

No suggestion. The function returns on the next line anyways.

@brother
Copy link
Collaborator

brother commented Jun 17, 2024

The warning is correct. Ignore it with a directive if you don't like it.

@zefir-git
Copy link
Author

If cd fails, it will return on the next line anyways.

this doesn't make sense:

cd generated_files || return $?
return $?

Isn't this like?

int result = cd("generated_files");
if (result == 1) return result;
return result;

|| return when the next line already is return seems redundant to me.

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