AIThis post was created with the assistance of artificial intelligence (AI).

TL;DR

Before you orderOffer from Amazon

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
Start your free Prime trial Free trial for eligible customers · Cancel anytime
As an affiliate, we earn on qualifying purchases.

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.

At a glance
reportWhen: Published Oct. 2, 2026
The developmentA programming blog report published Oct. 2 describes how quoted tilde characters in shell startup files can create a misleading PATH entry and how to check for it.

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

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

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

Philips Sonicare 5950 Rechargeable Electric Toothbrush with 2 Brush Heads, Pink

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

Wellness content on this site is informational and not a substitute for professional medical guidance.
You May Also Like

Arista Networks Surges In Global Coverage

Arista Networks is experiencing a surge in international coverage, with 25 mentions in recent media analysis, signaling increased industry interest.

DDA Launches Online FAQs To Explain Delhi Master Plan 2047 – The Hindu

Delhi Development Authority introduces online FAQs to clarify key aspects of the Delhi Master Plan 2047, aiming to improve public understanding and transparency.

Twitter Outage

Twitter faced a widespread outage on April 27, 2024, affecting user access globally. The cause is under investigation, with no official cause confirmed yet.

“Incubators Of The World”. Tel-Aviv, Thursday 30Th July. Our Speaker. Alon Turkaspa, Director Of Global Partnerships At Start-Up Nation Central. – IsraelValley

Alon Turka, Director of Global Partnerships at Start-Up Nation Central, discussed the role of incubators worldwide during the ‘Incubators of the World’ event in Tel-Aviv on July 30.