SC2114 – ShellCheck Wiki

See this page on GitHub


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


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.


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.

ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.