A user reported an issue while using the nono agent sandboxing tool, which displayed a warning regarding the PATH entries it can write to: ~/.local/bin/. The warning indicated that the tilde (~) may not expand to the user's home directory as expected. According to Bash documentation, tilde expansion occurs only in unquoted inputs. Specifically, if a word begins with an unquoted tilde character, all characters up to the first unquoted slash are treated as a tilde-prefix. Bash checks each variable assignment for unquoted tilde-prefixes immediately following a colon or the first equals sign, performing tilde expansion in these cases. This means that instead of adding /home/<user>/.local/bin/ to the PATH, it results in ./~/.local/bin/ being added. However, the unquoted version export PATH=$PATH:~/.local/bin does work in Bash and Zsh, as tilde expansion is also performed in variable assignments after the equals sign and after each colon. It is important to note that relying on this can be fragile, as whitespace can disrupt the variable assignment. Users can check for this issue by running a specific command, and if it prints anything, they should modify their .bashrc, .zshrc, or .profile files to replace the tilde with $HOME. The nono tool received praise for its warning, although it was suggested that the warning could be more detailed.
✓ No loaded language, vague sourcing, or framing detected.
Understanding Tilde Expansion in Bash and Zsh PATH Variables
A user encountered a warning from the nono agent sandboxing tool about tilde expansion in PATH variables. The issue arises when the tilde does not expand to the home directory as expected, potentially leading to incorrect PATH entries. Users are advised to replace the tilde with $HOME in their configuration files to avoid this problem.
No note attached
on this article.
Original vs. Neutral
The tilde in your PATH may not be your HOME
Understanding Tilde Expansion in Bash and Zsh PATH Variables