Shellcheck: Suggestion: Detect invalid number of arguments to 'ln -s'

Created on 22 Dec 2017  路  9Comments  路  Source: koalaman/shellcheck

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/your/interpreter
ln -s "$foo $bar"

Here's what shellcheck currently says:

Nothing

Here's what I wanted or expected to see:

Some sort of error output.

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 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.

All 9 comments

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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arth1 picture arth1  路  4Comments

nathaniel112 picture nathaniel112  路  4Comments

koalaman picture koalaman  路  4Comments

phagara picture phagara  路  4Comments

mechalynx picture mechalynx  路  5Comments