this post was submitted on 05 Mar 2025
1572 points (99.0% liked)
Programmer Humor
21016 readers
2526 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I honestly think autocorrecting your scripts would do more harm than good. ShellCheck tells you about potential issues, but It's up to you to determine the correct behavior.
For example, how could it know whether
cat $foo
should becat "$foo"
, or whether the script actually relies on word splitting? It's possible that$foo
intentionally contains multiple paths.Maybe there are autofixable errors I'm not thinking of.
FYI, it's possible to gradually adopt ShellCheck by setting
--severity=error
and working your way down to warnings and so on. Alternatively, you can add one-off#shellcheck ignore SC1234
comments before offending lines to silence warnings.Last time I used ShellCheck (yesterday funnily enough) I had written
ports+=($(get_elixir_ports))
to split the input sinceget_elixir_ports
returns a string of space separated ports. It worked exactly as intended, but ShellCheck still recommended to make the splitting explicit rather than implicit.The ShellCheck docs recommended