shellcheck
shellcheck copied to clipboard
SC2064 is questionable
There are many reasons to use double quoted, immediate evaluation strings for traps. Basically, to parameterize them.
Isn't it covered by the Exceptions?
If you don't care that the trap code is expanded early because the commands/variables won't change during execution of the script, or because you want to use the current and not the future values, then you can ignore this message.
hen you can ignore this message.
That's what I'm griping about! I think the exceptions outnumber the utility of this rule.
Well for bash at least, I think the heuristic should be, if the variable(s) are readonly (constant) then it shouldn't trigger.
That's great for bash. But I strive to write pure POSIX sh for portability.
POSIX supports read only: https://pubs.opengroup.org/onlinepubs/009695299/utilities/readonly.html
So that should be reasonable as well. It just is mutable results that might not do what users expect.
Just seconding that this rule is inverted to my expectations as well.
Lazy evaluation feels like the more surprising mistake. Double quotes evaluating now is not surprising in shell.
3.3k disables https://github.com/search?q=SC2064&type=code