mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC2083 (markdown)
30
SC2083.md
Normal file
30
SC2083.md
Normal file
@@ -0,0 +1,30 @@
|
||||
## Don't add spaces after the slash in './file'
|
||||
|
||||
### Problematic code:
|
||||
|
||||
```sh
|
||||
gcc -o myfile file.c
|
||||
./ myfile
|
||||
```
|
||||
|
||||
### Correct code:
|
||||
|
||||
```sh
|
||||
gcc -o myfile file.c
|
||||
./myfile
|
||||
```
|
||||
### Rationale:
|
||||
|
||||
Contrary to popular belief, there is no command or syntax `./` that runs a file.
|
||||
|
||||
`./myfile` is simply the shortest path equivalent to `myfile` that specifies a directory and therefore causes a shell to run it as-is, instead of trying to find its directory using $PATH.
|
||||
|
||||
Therefore, to run a file in the current directory, use `./myfile` and not `./ myfile`.
|
||||
|
||||
### Exceptions:
|
||||
|
||||
None
|
||||
|
||||
### Related resources:
|
||||
|
||||
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
|
Reference in New Issue
Block a user