-
Notifications
You must be signed in to change notification settings - Fork 9
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
Unexpected execute_shellcheck
behavior
#460
Comments
Hello, thank you for reaching out. I have tried to reproduce your issue. $ bash
$ cat script.sh
#!/bin/bash
echo 'hi there'
if [ $? -ne 0 ]; then
echo 'success'
fi
printf "%s hey\n"
printf "hi there %s\n"
$ execute_shellcheck () {
true && local external_sources=--external-sources
local shellcheck_args=(
--format=json1
"${external_sources:-}"
--severity="style" # <-- "${INPUT_SEVERITY}"
"${@}"
)
local output
output=$(shellcheck "${shellcheck_args[@]}" 2> /dev/null)
echo "${output}"
}
$ execute_shellcheck script.sh
{"comments":[{"file":"script.sh","line":4,"endLine":4,"column":6,"endColumn":8,"level":"warning","code":2320,"message":"This $? refers to echo/printf, not a previous command. Assign to variable to avoid it being overwritten.","fix":null},{"file":"script.sh","line":4,"endLine":4,"column":6,"endColumn":8,"level":"style","code":2181,"message":"Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.","fix":null},{"file":"script.sh","line":8,"endLine":8,"column":8,"endColumn":18,"level":"warning","code":2183,"message":"This format string has 1 variable, but is passed 0 argument.","fix":null},{"file":"script.sh","line":9,"endLine":9,"column":8,"endColumn":23,"level":"warning","code":2183,"message":"This format string has 1 variable, but is passed 0 argument.","fix":null}]} The problem in your reproducer was that you didn't set style input, which is passed to the script as ENV. If I wouldn't redirect stderr to /dev/null you would see the following error:
It seems that But you can configure it in a way that it will always report all the reports if it is what you want - please see https://github.com/redhat-plumbers-in-action/differential-shellcheck?tab=readme-ov-file#diff-scan |
Hi @jamacku! Thanks for the quick reply, and for the correction to my repro. I'll test out what you said above and reply back here soon! ❤️ |
Hey @jamacku, I did indeed try again with no success. But, after doing some more reading, I'm pretty sure it wasn't working because of the case outlined here, which was exactly what I was doing (running |
Type of issue
Bug (unexpected behavior).
Description
Hi! First, this project is great. TYSM for making/maintaining it.
Second, I'm hitting some unexpected behavior with this GitHub action. After doing some digging into the container's internals (after the GitHub action wasn't behaving as I expected), it looks like calls to
execute_shellcheck
and rawshellcheck
calls behave differently (see below, which is output from inside the container):I'd expect
execute_shellcheck
and rawshellcheck
to act the same (same output and return code), but it doesn't seem like they are.The questions I have are: Is this the expected behavior? Or is there a bug here? Or, do I have something misconfigured on my end (a very real possibility)?
Last, the
job
in my GitHub actions file is as follows:TYSM. 😄
Describe the solution you'd like
A bug fix if this is a bug, and working config options if this is a PEBKAC. ❤️
The text was updated successfully, but these errors were encountered: