Created SC2114 (markdown)

koalaman
2015-01-25 12:07:54 -08:00
parent 16990d36ab
commit d36ba6696c

23
SC2114.md Normal file

@@ -0,0 +1,23 @@
## Warning: deletes a system directory. Use 'rm --' to disable this message.
### Problematic code:
rm -rf /usr /lib/nvidia-current/xorg/xorg
### Correct code:
rm -rf /usr/lib/nvidia-current/xorg/xorg
### Rationale:
The example line of code was an actual bug in the [Bumblebee NVIDIA driver](https://github.com/MrMEEE/bumblebee-Old-and-abbandoned/commit/a047be85247755cdbe0acce6f1dafc8beb84f2ac).
Due to an accidental space, it deleted `/usr` instead of just the particular directory.
### 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 `--`:
rm -rf -- /usr
This is an arbitrary convention to allow deleting such directories without having to use a [[directive]] to silence the warning.