✓ AI-Debiased Article
Rewritten from Hacker News — Front Page • • 1 min read
4 Wire-neutral provisional

✓ No loaded language, vague sourcing, or framing detected.

Understanding Tilde Expansion in Bash and Zsh

A user encountered a warning from the nono agent sandboxing tool regarding PATH entries related to tilde expansion in Bash and Zsh. The user explained that tilde does not expand to the home path in quoted inputs and provided a solution for correcting this in configuration files.

A user reported an issue while using the nono agent sandboxing tool, which displayed a warning regarding PATH entries that the sandbox can write to, specifically ~/.local/bin/. The user explained that when modifying the ~/.bashrc or ~/.zshrc files, the tilde (~) does not expand to the home path ($HOME) in quoted inputs. According to Bash documentation, tilde expansion occurs only when a word begins with an unquoted tilde character. Bash checks for unquoted tilde-prefixes immediately following a colon (:) or the first equals sign (=) and performs tilde expansion in these cases. As a result, instead of adding /home/<user>/.local/bin/ to the PATH, the entry ./~/.local/bin/ is added. The user noted that while the command export PATH=$PATH:~/.local/bin works in Bash and Zsh, it is fragile, as any whitespace can disrupt the variable assignment. The user provided a method to check for this issue and suggested replacing the tilde with $HOME in configuration files. They also acknowledged the nono tool for its warning, suggesting that it could be more detailed.

Annotating as

No note attached

on this article.

Original vs. Neutral

Original Headline

Don't Put Tilde In Your Path

Neutral Headline

Understanding Tilde Expansion in Bash and Zsh