to use ~ as file .. '~' n "~" or ./~
On Wed, Feb 12, 2025, 5:21 PM Andrés Rodríguez Reina <are...@gmv.com> wrote: > Subject: [Suggestion] Add warning/error when using the tilde expansion in > a folder where the tile-named file/folder exists > > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -g -O2 > -fdebug-prefix-map=/build/bash-Smvct5/bash-5.0=. -fstack-protector-strong > -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-security > uname output: Linux ltarrr 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu > Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux > Machine Type: x86_64-pc-linux-gnu > > Bash Version: 5.0 > Patch Level: 17 > Release Status: release > > Description: > Due to a mistake in coding a script, a folder named '~' was > generated. An unexperienced bash user issued the command "rm -rf ~" by > mistake, intending to delete the '~' folder, but this resulted in deleting > 150GB+ of data at their home directory. > In my opinion, it would be useful to have a warning be issued when > in interactive mode, when at the current working directory a file/folder > named '~' exists, and a command with a parameter starting with ~ is used > (which will produce tilde expansion). > > Repeat-By: > Create a file/folder named '~': mkdir '~' > Try to delete it with a bogus command (DO NOT EXECUTE): rm -rf ~ > > Fix: > When in interactive mode and when a suitable flag is activated, an > error should appear. For example: > <Error: use of ~ is ambiguous. Please either specify '~' or type > the home path to avoid ambiguity.> > > Thank you for your time, > Andres R >