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

util.sh has invalid test #5

Open
jessebutryn opened this issue Oct 26, 2019 · 1 comment
Open

util.sh has invalid test #5

jessebutryn opened this issue Oct 26, 2019 · 1 comment

Comments

@jessebutryn
Copy link

jessebutryn commented Oct 26, 2019

Line 234 in util.sh is testing the exit code of the previous command but suffers from SC2155

Since local is being used for the variable assignment that line will always exit with 0.

Testing:

test-func () { local var=$(this-is-not-a-real-command); echo $? ;}
$ test-func
-bash: this-is-not-a-real-command: command not found
0

Due to this I believe it should be modified to:

    local manta_url
    manta_url=$(json -f "${METADATA}" MANTA_URL)
    [[ $? -eq 0 ]] || fatal "Unable to retrieve MANTA_URL from metadata"

Note: This issue is also found on line 217

@jessebutryn
Copy link
Author

jessebutryn commented Oct 26, 2019

Additionally you can test on the command/assignment itself:

local manta_url
if ! manta_url=$(json -f "${METADATA}" MANTA_URL); then
  fatal "Unable to retrieve MANTA_URL from metadata"
fi

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