From d36ba6696c0f66958327337dc5df48d724f34f86 Mon Sep 17 00:00:00 2001 From: koalaman Date: Sun, 25 Jan 2015 12:07:54 -0800 Subject: [PATCH] Created SC2114 (markdown) --- SC2114.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 SC2114.md 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