#!/your/interpreter
ln -s "$foo $bar"
Nothing
Some sort of error output.
Non-POSIX but still quite commonly supported: https://unix.stackexchange.com/questions/219038/why-does-ln-s-accept-a-single-argument
This request is no longer checking the shell script for shell scripting issues; it is checking the invocation of command line programs. That smacks of feature creep, especially given the observation that the specific ln notation is quite widely supported.
More particularly, where does this stop. Will you require shell check to monitory mv and cp too? What about chmod? Can you check ls? What about find?
I don't think this is something shellcheck should be trying to handle.
@jleffler Shellcheck already went into that direction (giving warnings about tools which aren't common shell builtins), see e.g.:
ShellCheck definitely aims to warn about common bad usage patterns of external commands, but it does not intend to generally validate usage.
Whether or not this warrants a check depends on how commonly it occurs, what the false positive rate would be, and how hard it is to solve the problem without ShellCheck's help (cp foo gives a clear message, but I had no idea ln foo was a valid invocation).
I'll have a look at a corpus of scripts to see how frequent this is.
This had an occurrence of less than 1 in 1000 scripts, but there were some interesting and hard-to-spot cases and no false positives among the thousands of cp/ln/mv statements, so I added checks. Thanks!
@koalaman Thank you very much, I will update from trunk at work tomorrow.
Worked like a charm over here, good job! And it error'ed on the faulty use as well.
@koalaman seems like you missed to update the ChangeLog fwith this fix.
Thanks, I've updated the changelog in 1d0db92. I'm still getting used to having one.
Most helpful comment
This request is no longer checking the shell script for shell scripting issues; it is checking the invocation of command line programs. That smacks of feature creep, especially given the observation that the specific
lnnotation is quite widely supported.More particularly, where does this stop. Will you require shell check to monitory
mvandcptoo? What aboutchmod? Can you checkls? What aboutfind?I don't think this is something shellcheck should be trying to handle.