-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
For bugs with existing features
- Related to Suggestion: Detect invalid number of arguments to 'ln -s' #1080
- version: 0.11.0
- The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
- I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit
Here's a snippet or screenshot that shows the problem:
$ POSIXLY_CORRECT=1 ln --force --symbolic target -- file
ln: target 'file': No such file or directory
$ touch file
$ POSIXLY_CORRECT=1 ln --force --symbolic target -- file
ln: target 'file': Not a directoryWhat's happening is that ln can take two arguments, but POSIX ln doesn't recognise that -- isn't meant to be a filename; it's treating file as the directory to place the symbolic link under, hence the error messages.
cp & mv also suffer from this issue (e.g. POSIXLY_CORRECT=1 cp file -- file2 will fail, though strangely, POSIXLY_CORRECT=1 cp -- file file2 succeeds). There could be other tools as well, but these are the most common ones I thought to test.
Here's what shellcheck currently says:
Nothing.
Here's what I wanted or expected to see:
"Under POSIX, -- is treated as a literal filename by cp, mv, and ln."
Metadata
Metadata
Assignees
Labels
No labels