Re: [Suggestion] Add warning/error when using the tilde expansion in a f
From:
Lawrence Velázquez
Subject:
Re: [Suggestion] Add warning/error when using the tilde expansion in a folder where the tile-named file/folder exists
Date:
Wed, 12 Feb 2025 14:27:03 -0500
On Wed, Feb 12, 2025, at 2:02 PM, Andrés Rodríguez Reina wrote:
> And I also
> agree that any other substitution is subject to cause the same
> confusion, but the case with the tilde expansion produces more damage
> to inexperienced users. I mean: "rm -rf *" just deletes the whole
> folder contents, while "rm -rf ~" deletes all your files (similarly
> with other destructive commands).
Depending on the current working directory, "rm -rf *" could easily
be more catastrophic than "rm -rf ~".
> For example: "rm -rf /" is also unambiguous, yet the command warns you
> about the possible unintended consequences.
>
> In any case, I'd say that in interactive mode and with a specific flag
> active, I could find useful that no command with a $name/*/~/etc is
> executed when a file by the same name is present at the current
> directory.
It's one thing for a command that knows its own destructiveness to
warn about that. It's another for the shell itself to do a bunch
of I/O before even beginning to process a command that might end
up being benign.
> Advanced users can easily disable the flag and obtain full
> power/risk.
I'm not sure this would fly as the new default.
--
vq