Urgent.News

What's breaking now, across thousands of outlets.

Tech

The tilde in your PATH may not be your HOME

Article URL: https://disconnect3d.pl//2026/10/02/dont-put-tilde-in-your-path/ Comments URL: https://news.ycombinator.com/item?id=50042425 Points: 195 # Comments: 135

A recent issue surfaced while testing the nono agent sandboxing tool, which alerted users to a potential problem with their PATH environment variable. Specifically, the sandbox detected entries in PATH that could be written to, such as ~/.local/bin/. The warning suggested that simply adding ~ (tilde) to the PATH could lead to unexpected behavior, as the tilde expansion only occurs in unquoted inputs.

According to the bash documentation, tilde-prefixes, which begin with an unquoted tilde character (~), are expanded only when followed by the first unquoted slash (/) or the first equals sign (=). This means that if a user includes ~ in their PATH, it will expand to the current user's home directory only if the tilde is not enclosed within quotes.

In the example given, instead of adding /home/user/.local/bin/ to PATH, the sandbox encountered ./~/.local/bin/ added to PATH. This discrepancy occurred because the tilde expansion was performed in the variable assignment after the equals sign (=) or after each colon (:). However, relying on this behavior is considered fragile, as it can be broken by whitespace or other factors.

To check for this issue, users can run a simple command that prints the PATH, replacing all instances of ~ with $HOME. If the command outputs anything, it indicates that the PATH should be updated with the correct $HOME notation. The nono tool provided a valuable warning about this potential issue, although it could benefit from more detailed explanations in the future.

Written by urgent.news from Hacker News Best's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at disconnect3d.pl →

More in Tech

Hackers use security cameras to track troops, military targets in Israel, Ukraine - report

One incident highlighted in the investigation involved a poultry farmer in northern Israel who discovered that the language settings on a camera overlooking his chicken coop had changed to Arabic.

  • National Cyber Directorate warns of camera vulnerabilities during June 2025 Israel-Iran conflict.
  • Russia and Ukraine exploit compromised surveillance systems for battlefield intelligence.

More from Sunday 11 October →