mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC2226 (markdown)
36
SC2226.md
Normal file
36
SC2226.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
## This ln has no destination. Check the arguments, or specify '.' explicitly.
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ln "$file $dir"
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ln /foo/bar/baz
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ln "$file" "$dir"
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ln /foo/bar/baz .
|
||||||
|
```
|
||||||
|
### Rationale:
|
||||||
|
|
||||||
|
ShellCheck found a `ln` command with a single parameter. This may be because the source and destination was accidentally merged into a single argument, because the line was broken in an invalid way, or because you're using a non-standard invocation of `ln` that defaults to linking the argument into the current directory.
|
||||||
|
|
||||||
|
If you wanted to specify both source and destination, fix the `ln` statement.
|
||||||
|
|
||||||
|
If you wanted to link a file into the current directory, prefer using the more explicit and POSIX standard invocation `ln /your/file .`
|
||||||
|
|
||||||
|
### Exceptions:
|
||||||
|
|
||||||
|
None.
|
Reference in New Issue
Block a user