mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC2114 (markdown)
@@ -1,4 +1,4 @@
|
|||||||
## Warning: deletes a system directory. Use 'rm --' to disable this message.
|
## Warning: deletes a system directory.
|
||||||
|
|
||||||
### Problematic code:
|
### Problematic code:
|
||||||
|
|
||||||
@@ -20,10 +20,11 @@ Due to an accidental space, it deleted `/usr` instead of just the particular dir
|
|||||||
|
|
||||||
### Exceptions:
|
### Exceptions:
|
||||||
|
|
||||||
In cases of chroot, initramfs and similar, it's reasonable to delete otherwise important directories. Due to this, Shellcheck will not warn if the command contains `--`:
|
If you do intend to delete a system directory, such as when working in a chroot or initramfs, you can disable this message with a directive:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
rm -rf -- /usr
|
# shellcheck disable=SC2114
|
||||||
|
rm -rf /usr
|
||||||
```
|
```
|
||||||
|
|
||||||
This is an arbitrary convention to allow deleting such directories without having to use a [[directive]] to silence the warning.
|
Previous versions of shellcheck, up to and including 0.4.6, would ignore `rm` statements containing a `--` (an arbitrary convention). This is no longer the case.
|
Reference in New Issue
Block a user