Closed fbartels closed 4 years ago
@haya14busa ok, I think I am good for the moment.
PS: in the output of the action it says reviwedog: Reporting results for "shellcheck"
is that a typo in reviewdog?
PS: in the output of the action it says reviwedog: Reporting results for "shellcheck" is that a type on reviewdog?
Thanks for the catch! It's typo. I'll fix it.
Can you add a flag to use grep & shebang instead of removing find command usage?
I had thought of that before, but to me it seemed like this would duplicate a lot of code. the leanes way possible I could think of was putting the file listing into a bash function and then pipe the result to shellcheck (and the function could have a if for grep vs. find). I ultimately decided against it, since it did not seem like worth the effort, since ...
Not all shell scripts have shebang.
I think this is just educating users into the wrong direction. What valid reason could there be not to have a shebang? is that the only reason find could be preferred over grep?
pseudo code
FILES=""
if pattern is not empty
FILES=$(find ...)
else
FILES=$(grep ...)
fi
shellcheck ... $FILES | reviewdog ...
In my understanding shell script files used as a library don't need to have shebang as per shebang's purpose for example.
You mean when the file is sourced by another script? That's true in that case there does not need to be a shebang, but even in the original version of your script you were using "--external-sources" to tell shellcheck to also check sourced files.
But the both of us have obviously different perspectives on that matter, which is of course allowed. I think I'll just maintain my own version of this repo to not introduce too many breaking changes for existing users of it.
Sigh. Seems like the correct answer is to do both all files that contain a shebang plus any pattern the user specifies. If the user doesn't specify a pattern and the file has no shebang, there's nothing we can do about it. If they want us to check all .sh files we should do that regardless of whether there's a shebang.
This should easily be doable without too much fuss or code duplication with something like:
(grep "${GREP_ARGS[@]}" ; find "${FIND_ARGS[@]}") | sort -u | xargs shellcheck ...
Sadly I don't have time to implement or test this myself.
@haya14busa sorry if I'm asking you to repeat yourself, but what exactly is your position on this matter? is @lsgunth suggestion acceptable? I wouldn't mind implementing a PR if I can get some pointers, this would be a huge boon for the project I'm currently developing as part of GSoC since not being able to specify multiple patterns is a huge issue for us
fixes #2
Signed-off-by: Felix Bartels felix@host-consultants.de