On Fri, May 30, 2025, at 3:36 AM, Martin Schulte wrote: > https://www.gnu.org/software/bash/manual/bash.html#Bash-POSIX-Mode says: > > 19. Literal tildes that appear as the first character in elements of > the PATH variable are not expanded as described above under Tilde > Expansion. > > Is this no longer true from version 5.2 on? > > $ bash --posix -c 'echo $BASH_VERSION; PATH=~/x:~/y; echo $PATH' > 5.1.4(1)-release > /home/schulte/x:~/y > $ bash-5.2.37 --posix -c 'echo $BASH_VERSION; PATH=~/x:~/y; echo $PATH' > 5.2.37(1)-release > /home/schulte/x:/home/schulte/y
The excerpt you pulled from the manual is about tilde expansion performed during PATH lookup, not as part of variable assignment. That is, by default this works even though the new value of PATH contains a literal tilde: $ mkdir -p ~/bin $ printf '%s\n' '#!/bin/sh' 'echo hi' >~/bin/hi $ chmod a+x ~/bin/hi $ PATH=\~/bin $ declare -p PATH declare -x PATH="~/bin" $ hi hi But not in POSIX mode: $ set -o posix $ hash -r $ hi bash: hi: command not found See this recent thread for a bit more: https://lists.gnu.org/archive/html/bug-bash/2025-01/msg00114.html Your example commands demonstrate something else. The command PATH=~/foo:~/bar has always assigned a value like '/myhome/foo:/myhome/bar', POSIX mode or not. This is broken in bash 5.1 POSIX mode unless patch 13 is applied: https://lists.gnu.org/archive/html/bug-bash/2022-01/msg00008.html -- vq