On 28/07/17 09:28, R0b0t1 wrote:
> I recently had a script create a file named "~" when I passed it a
> value for an installation directory. Without thinking the next command
> I typed was the one in the title. Luckily this was not my main
> computer and was a virtual machine.
> 
> It does not seem likely a user will ever intentionally type `rm -rf
> ~`. Deletion of home directories usually takes place as another user.
> Most of the arguments used for the addition of --no-preserve-roots and
> the `rm -rf /` safeties also seem to apply in this case, as just as
> one could erroneously type `rm -rf / directory` one could type `rm -rf
> ~ /directory` (or even the impressive yet redundant `rm -rf ~ /
> directory`).

This was one of the reasons that upstream ls defaults to quoting
problematic file names like this. With that you can always
copy and paste the name ('~' in this case), for subsequent use.
Even if not copy/pasting '~' would give a visual indication
that the quoting was needed. If your distro disables that feature,
you can enable it in your ls alias using --quoting='shell-escape'

cheers,
Pádraig




Reply via email to