On 2025-02-03 22:19, microsuxx wrote:
~ $ p=~:~:~ ; declare -p p
declare --
p="/data/data/com.termux/files/home:/data/data/com.termux/files/home:/data/data/com.termux/files/home"
~ $ cp $( type -P bash ) sh
~ $ ./sh
sh-5.2$ x=~:~:~:
sh-5.2$ declare -p x
declare --
x="/data/data/com.termux/files/home:/data/data/com.termux/files/home:/data/data/com.termux/files/home:"
sh-5.2$ set -o posix
sh-5.2$ f=~:~:~
sh-5.2$ declare -p f
declare --
f="/data/data/com.termux/files/home:/data/data/com.termux/files/home:/data/data/com.termux/files/home"
im under the impression
by ur code examples
.. in quotes , ~ doesnt expand
This demonstration confirms that in Bash, an unquoted tilde (e.g. ~) in
a variable assignment is immediately expanded to the full home
directory—this happens consistently whether Bash is running normally, as
sh, or in POSIX mode. However, when used in the PATH variable,
interactive Bash expands the tilde at command execution time while
sh/Posix mode does not, which can lead to unexpected behavior. For
portability, it's best to use $HOME explicitly (e.g. $HOME/bin), and
this inconsistency should be clearly documented in the Bash Reference
Manual.
Zeffie