TL;DR
Get wellness gear delivered free with Prime
- Fast, free delivery on millions of items
- Prime Video, Amazon Music and more included
- Member-only deals all year
A report by Disconnect3d explains that putting `~` inside a quoted PATH assignment can leave it unexpanded, so the shell may search a literal `~` directory rather than the home directory. The report recommends using `$HOME` and provides commands to check PATH entries.
A report published by programmer Disconnect3d on Oct. 2 warns that putting a tilde in a quoted PATH assignment, such as export PATH="$PATH:~/.local/bin/", may leave the tilde literal rather than expand it to the user’s home directory. The result can make a shell search a relative directory named ~ instead of the intended ~/.local/bin under the home directory.
The report says the issue came to light when the author used nono, an agent sandboxing tool, which warned that a PATH entry the sandbox could write to appeared to be ~/.local/bin/. The author traced the entry to a quoted assignment in a shell startup file, such as .bashrc or .zshrc. In that form, the tilde is inside quotes and does not undergo the usual home-directory expansion.
Disconnect3d demonstrated the behavior by creating a program in a directory literally named ./~/.local/bin/ and setting PATH to ~/.local/bin/. The shell found and ran the program from that relative location. The example shows that the command can appear to work even though the home directory was not used.
The suggested replacement is export PATH="$PATH:$HOME/.local/bin/". The author also notes that an unquoted form, export PATH=$PATH:~/.local/bin, works in Bash and Zsh because those shells expand tildes after an equals sign and after a colon in assignments. But the report describes that approach as fragile: adding whitespace can change how the shell parses the assignment.
A PATH Entry Can Point Elsewhere
PATH tells a shell which directories to search when a user types a command without specifying its full location. A mistaken entry can lead to a command being found in an unintended place. In the report’s example, a binary in a local directory named ~ ran because that directory was included in PATH, not because the shell reached the user’s home directory.
That distinction can matter when developers install or run tools from personal directories, and it can complicate debugging when a command behaves differently across machines or working directories. The report does not claim that every quoted tilde in PATH creates an exploitable security issue; the demonstrated concern is that the entry may point somewhere other than its author intended. Checking the actual PATH entries helps establish which directories the shell is searching.
Products Worth Considering

Blueair Blue Pure 511i Max Smart Air Purifier

Withings BPM Connect Blood Pressure Monitor with Wi-Fi and Bluetooth

Philips Sonicare 5950 Rechargeable Electric Toothbrush with 2 Brush Heads, Pink
As an affiliate, we earn on qualifying purchases.
How Shell Tilde Expansion Works
In Bash, tilde expansion ordinarily applies when a word begins with an unquoted tilde. The Bash documentation also describes expansion in assignment values immediately after an equals sign and after a colon, provided the tilde prefix is unquoted. That behavior explains why the unquoted assignment in the report works in Bash and Zsh, while quoting the whole value prevents the intended expansion.
Disconnect3d’s suggested check is echo "$PATH" | grep -- '~'. To inspect entries individually, the report gives echo "$PATH" | tr ':' '\n' | grep '~'. If either command prints an entry, the author advises reviewing the relevant .bashrc, .zshrc or .profile and replacing the tilde with $HOME where appropriate. The output is a prompt to inspect the configuration, not proof by itself that every matching entry is wrong.
Check the Entry Before Changing It
The report does not establish how common the configuration mistake is or measure how many users are affected. It also does not say that every PATH entry containing a tilde is necessarily incorrect: the meaning depends on how the entry was created and the shell in use. A matching result from the suggested grep command identifies a tilde in PATH, but users still need to check whether that entry is intended and where it resolves.
The author says the warning from nono could be more verbose and mentions that a pull request was forthcoming. The report does not provide a later status for that proposed change. It also offers examples for Bash and Zsh; behavior in other shells is not established by the material provided.
Review Startup Files and PATH
Users concerned about the issue can inspect PATH one entry at a time, then review the shell startup file that added any unexpected value. Where the intended destination is the home directory, the report recommends using $HOME in the assignment, then opening a new shell or reloading the relevant configuration and checking the resulting PATH.
Disconnect3d’s report also points to a possible follow-up: a more detailed warning in nono. The author said a pull request was incoming, but no acceptance or release was confirmed in the report. Until that status is known, the practical next step is to verify the path directly rather than assume a displayed tilde refers to HOME.
Key Questions
Does a tilde in a quoted PATH assignment always expand to HOME?
No. The report’s example, export PATH="$PATH:~/.local/bin/", keeps the tilde literal because it is quoted. Use $HOME when the intended path is under the home directory.
How can I check whether PATH contains a tilde?
Run echo "$PATH" | tr ':' '\n' | grep '~' to print matching entries on separate lines. Then inspect whether each one is intended and what directory it refers to.
Can a command still run if the tilde was not expanded?
Yes. Disconnect3d demonstrated a command running from a relative directory literally named ~. That does not mean it ran from the home directory.
Is the unquoted tilde version a reliable fix?
The report says the unquoted assignment works in Bash and Zsh because of tilde expansion in assignment values. The author calls it fragile because whitespace can affect parsing, and recommends using $HOME instead.
Source: hn
