4 SC2114
haruna edited this page 2021-05-21 04:17:44 +09:00

Warning: deletes a system directory.

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.

Due to an accidental space, it deleted /usr instead of just the particular directory.

Exceptions:

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:

# shellcheck disable=SC2114
rm -rf /usr 

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.