Re: Tilde is expanded in $PATH, inconsistent behavior
From:
Lawrence Velázquez
Subject:
Re: Tilde is expanded in $PATH, inconsistent behavior
Date:
Mon, 03 Feb 2025 16:11:00 -0500
On Mon, Feb 3, 2025, at 2:57 PM, Dale.Worley@comcast.net wrote:
> Within that context, if an element of PATH contains a '~' character, you
> don't expect that to cause execution requests to look in your home
> directory, because '~' isn't the name of your home directory.
Yes, that was the whole point of Keith's original email. He was
OBJECTING to the behavior and suggesting that it be deprecated but
documented in the meantime.
> For that matter, Bash doesn't search the path for executables
It does. That's why this works:
$ echo 'echo hi' >~/greet
$ chmod +x ~/greet
$ PATH='/opt/local/bin:~'
$ ksh -c greet
ksh: greet: not found
$ bash -c greet
hi
> the
> kernel uses the PATH of the process to find the file whose execution was
> requested.
Bash uses execve(2), which does not search PATH.
--
vq