Thank you for taking the time to review this suggestion.

I agree that tilde expansion is not ambiguous, this suggestion is here just to 
help clear the ambiguity in the user's mind/intent. 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).

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. Advanced users can 
easily disable the flag and obtain full power/risk.

Best regards,
Andrés

-----Original Message-----
From: Lawrence Velázquez <v...@larryv.me> 
Sent: 12 February 2025 19:46
To: Andrés Rodríguez Reina <are...@gmv.com>
Cc: Marina López Seoane <marina.lopez.seo...@gmv.com>; bug-bash@gnu.org
Subject: Re: [Suggestion] Add warning/error when using the tilde expansion in a 
folder where the tile-named file/folder exists

On Wed, Feb 12, 2025, at 10:50 AM, Andrés Rodríguez Reina wrote:
>         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).

You could say this about any unexpanded word.

        touch '$var'
        echo $var

        touch '*'
        ls *

        set -H
        touch '!$'
        stat !$

Should the shell look for a directory entry for every word before it does 
anything?


> 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.>

Tilde expansion may surprise inexperienced users, but there's nothing 
"ambiguous" about it.  It is well defined.


--
vq

P Please consider the environment before printing this e-mail.
  • [S... Andrés Rodríguez Reina
    • ... Lawrence Velázquez
      • ... Andrés Rodríguez Reina
        • ... Lawrence Velázquez
    • ... microsuxx
      • ... microsuxx
        • ... Andrés Rodríguez Reina via Bug reports for the GNU Bourne Again SHell
    • ... Dale R. Worley
    • ... Chet Ramey

Reply via email to