On Thu, Jan 23, 2025, at 6:37 PM, Keith Thompson wrote:
> Description:
>     A literal '~' or other tilde-prefix at the beginning of an
>     element of $PATH is expanded when a command is executed
>     from the bash prompt.  This is undocumented and inconsistent with
>     the behavior of other commands that can execute commands.
>
>     This expansion doesn't happen when bash is invoked as "/bin/sh"
>     (which is a symlink to bash on some systems).

The texinfo documentation mentions it as something that is disabled
in POSIX mode:

        19.  Literal tildes that appear as the first character in
             elements of the `PATH' variable are not expanded as
             described above under Tilde Expansion.

https://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html

>     There could be existing code that depends on it -- which I
>     suppose argues against removing it at all.  The documentation
>     should at least mention that the expansion occurs and discuss
>     this inconsistent treatment of $PATH by bash vs. other tools.

Perhaps this is another $[...] situation -- keeping the feature
around for compatibility, but leaving it undocumented to discourage
users from learning about and using it.

-- 
vq

Reply via email to