Conversation
Shellcheck changes
| @@ -1,4 +1,5 @@ | |||
| #!/usr/bin/env bash | |||
| # shellcheck source=/dev/null | |||
There was a problem hiding this comment.
I'm not sure this is something we want in examples. What does it do?
There was a problem hiding this comment.
It ensures that the shellcheck tool doesn't try to follow the path, since this path does not lead to a valid file in almost all cases.
There was a problem hiding this comment.
Why does it not lead to a valid file?
There was a problem hiding this comment.
Sorry, I thought this was on the other example files in the root, where the source paths there reference something that probably doesn't exist. Should those files even be there since these examples are given?
The issue here is working directory related. Running shellcheck from the scripts directory without this comment won't report any issues because the file exists.
The correct way to amend this is:
# shellcheck source-path=SCRIPTDIRWhich tells shellcheck to treat the path as if it were relative from the script's directory.
| @@ -1,4 +1,5 @@ | |||
| #!/usr/bin/env bash | |||
| # shellcheck source=/dev/null | |||
There was a problem hiding this comment.
Why does it not lead to a valid file?
Co-authored-by: Simon Lindholm <simon.lindholm10@gmail.com>
Co-authored-by: Simon Lindholm <simon.lindholm10@gmail.com>
Co-authored-by: Simon Lindholm <simon.lindholm10@gmail.com>
I ran the code through shellcheck which is de facto standard static analysis tool for shell scripts.
I made the changes required to pass, only ignoring a few warnings for the special use cases.
Why did I do this?
We are using shellcheck and include testdata_tools in our repos for contests so the library got flagged.
For libraries it is important to make sure errors/warnings don't disrupt the experience of the library user.