On Fri 2025-01-24 11:45:22 EST, Chet Ramey wrote: > On 1/23/25 9:15 PM, Keith Thompson wrote: > > > But I don't see anything in the "Tilde Expansion" section that > > documents the behavior of a literal '~' in $PATH. > > It remains undocumented.
Then I suggest that the phrase "as described above under Tilde Expansion" should be deleted (or that the feature should be documented). > > I suggest it would be better to document the behavior, since I imagine > > it's fairly easy to run into it accidentally. For example, something like > > > > PATH="~/bin:$PATH" > > > > will trigger the behavior. > > What do you think a user expects when they do something like this? How > many instances of this do you think exist out there? If you're going to > use something nonsensical like that, my guess is more people want the bash > behavior than not, as bad an idea as it is. First, let me acknowledge that this has not caused any problems for me. Feel free to consider that when prioritizing this. If I type PATH="$HOME/bin:$PATH" then I know that $HOME will be expanded to my home directory. $HOME and ~ are equivalent in many contexts. If I hadn't crawled down this particular rabbit hole, I might have (incorrectly but IMHO not unreasonably) assumed that PATH="~/bin:$PATH" would do exactly the same thing, with ~ expanding to my home directory. In fact, it instead puts a literal '~' character into my $PATH -- which will appear to work when I execute commands interactively, but fails when I execute a command from the bash prompt that then tries to invoke a command that happens to be under "$HOME/bin". I can also imagine someone seeing existing code that depends on this feature and trying to read the bash documentation to figure out what the heck is going on. Perhaps removing this behavior is not feasible, but I'm suggesting that it should be (briefly) documented with a warning against using it.