diff --git a/SC2114.md b/SC2114.md new file mode 100644 index 0000000..feb95a6 --- /dev/null +++ b/SC2114.md @@ -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. \ No newline at end of file