src/platform/path.cpp:95 decides whether to expand by looking at one character:
if (_path.string().substr(0, 1) == "~") {
Everything that follows the ~ is then appended to the home directory. That is wider than tilde expansion as it is normally understood.
What gets caught by mistake
A file whose name merely starts with ~ is treated as a home-relative path. Editor backup files (~backup.txt), lock files (~lock) and relative paths (~temp/file) all qualify. ~backup.txt in the working directory becomes $HOME/backup.txt.
What is not handled
~user/... — the form that names another user's home — is not resolved. The ~ is stripped and user/... is appended to the current user's home, so ~root/x becomes $HOME/root/x. The header says the method "Only processes paths that start with ~ or ~/", which does not describe either case.
Note
Deciding what the right rule is affects the contract, so this is not purely a fix. The narrow reading (~ alone, or ~ followed by a separator) matches what shells do for the current user and would leave ~user unresolved but also untouched.
src/platform/path.cpp:95decides whether to expand by looking at one character:Everything that follows the
~is then appended to the home directory. That is wider than tilde expansion as it is normally understood.What gets caught by mistake
A file whose name merely starts with
~is treated as a home-relative path. Editor backup files (~backup.txt), lock files (~lock) and relative paths (~temp/file) all qualify.~backup.txtin the working directory becomes$HOME/backup.txt.What is not handled
~user/...— the form that names another user's home — is not resolved. The~is stripped anduser/...is appended to the current user's home, so~root/xbecomes$HOME/root/x. The header says the method "Only processes paths that start with~or~/", which does not describe either case.Note
Deciding what the right rule is affects the contract, so this is not purely a fix. The narrow reading (
~alone, or~followed by a separator) matches what shells do for the current user and would leave~userunresolved but also untouched.