Unverified50% confidenceFactExact time
The contents of the PATH environment variable, when read by a system call (such as execvp), do not go through the shell's expansion process, so a ~ in PATH is treated as an ordinary character-based directory.
1
Sources
50%
Confidence
Long-term
Relevance
10/12/2026
First Seen
Sources
Related Entities
Related Claims
UnverifiedOne should avoid using the form export PATH="~/bin:$PATH", because ~ will not be expanded by system calls.79% similarUnverifiedThe root cause of ~ sometimes working and sometimes failing in PATH is that it can only be expanded when some intermediate link happens to invoke the shell to handle it.71% similarUnverified$HOME is a real environment variable, and referencing it constitutes parameter expansion, which the shell completes before executing the command, with the replacement result being the absolute path string of the home directory.66% similarUnverifiedInvocation paths that do not go through the shell (such as directly using execvp, posix_spawn, or the process-launching functions implemented in many languages' standard libraries) do not trigger tilde expansion, because they do not parse shell syntax.66% similarUnverifiedEnvironment variable assignments (such as $env:FOO=bar or export FOO=bar) are only effective in the current Shell process and its child processes, and become invalid when the terminal is closed; to take effect permanently, they need to be written into the Shell startup script (such as .bashrc, .zshrc, $PROFILE) or system environment variables.66% similar
Cite This Claim
Stable URI
https://kongchang.com/claim/1012611API
curl https://kongchang.com/api/v1/knowledge/claims/1012611MCP
get_claim(id=1012611)