From 12c257e624d3f1f80ca3df041b54026ff772d638 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 14:53:46 -0300 Subject: A path typed with a leading ~ is the home directory, at every entry point that takes one, through one helper Only DumpDir (dump.zig) and ShaderBuild expanded `~/`, each its own way. So a look at `~/notes.txt`, `name ~/x`, `Save ~/x`, ThemeFile, Restore and a quoted `pardes '~/x'` all took `~` as a directory of that name under the pane's. There is now one rule, filesystem.expandHome. A leading `~`, alone or before `/` or `:`, is $HOME, else the passwd entry's home; `~user` is that user's (getpwnam). As in a shell, it applies even beside a file named `~`, and `./~` names that file. Every entry point runs its typed path through it: - look, B3 and 9P, before any parsing, so `~/x:12`, `~/x:12:3` and `~/x:/re/` all work; - name, and a tag's rename; - Save ; - ThemeFile, DumpDir, Restore and ShaderBuild's shader files; - the forwarding launch. Recent rows are not shown with `~` and need nothing. How names are shown is unchanged. Tests: expandHome's cases, and HOME unset (passwd), with HOME passed in rather than set, since setenv moves the environ a spawned child reads. fs.py covers Save into missing directories under `~`, `name ~/x`, a look at `~/x:3`, and a forwarded `pardes '~/x'`. Co-Authored-By: Claude Opus 5.5 --- test/fs.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') diff --git a/test/fs.py b/test/fs.py index b02b9e45..55ec3257 100644 --- a/test/fs.py +++ b/test/fs.py @@ -383,6 +383,19 @@ def discovery(binary, embedded=False): client.remove(f'/pane/{scratch}') # A Save makes the directories its file goes in, whatever names # it: the pane's own name or Save's path. + # `~` is home (this session's HOME, the test's root) wherever a + # path is typed: Save, name, a look, with an address or not. + tilde = new_pane(client, b'one\ntwo\nthree\n') + client.write(f'/pane/{tilde}/ctl', b'Save ~/tilde-made/sub/x.txt\n') + assert (root / 'tilde-made/sub/x.txt').read_bytes() == b'one\ntwo\nthree\n' + client.write(f'/pane/{tilde}/name', b'~/tilde-named.txt\n') + assert client.read(f'/pane/{tilde}/name') == f'{root}/tilde-named.txt\n'.encode() + client.remove(f'/pane/{tilde}') + client.write('/look', b'~/tilde-made/sub/x.txt:3\n') + looked = [row for row in client.read('/index').decode().splitlines() if row.split()[3] == f'{root}/tilde-made/sub/x.txt'] + assert len(looked) == 1, client.read('/index') + assert client.read(f'/pane/{looked[0].split()[0]}/addr').startswith(b'8 '), client.read(f'/pane/{looked[0].split()[0]}/addr') + client.remove(f'/pane/{looked[0].split()[0]}') made_dirs = new_pane(client, b'deep\n') client.write(f'/pane/{made_dirs}/ctl', f'Save {root}/save-made/a/b/x.txt\n'.encode()) assert (root / 'save-made/a/b/x.txt').read_bytes() == b'deep\n' @@ -1333,6 +1346,15 @@ def test(binary, quic=False): execute(client, named, 'Save') client.remove(f'/pane/{named}') assert deep.read_bytes() == b'deep\n' + # `pardes '~/x'`, quoted so the shell left the `~`: home all the + # same: the launching shell's HOME. + before = serials() + quoted = subprocess.run([binary, '~/fwd-tilde.txt'], cwd=root, env=dict(env, HOME=str(root)), + stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, timeout=10) + assert quoted.returncode == 0, quoted.stderr + assert f'{root}/fwd-tilde.txt'.encode() in client.read('/index'), client.read('/index') + for serial in serials() - before: + client.remove(f'/pane/{serial}') # A name the session refuses: its reason and exit 1, as B's, # never a nested editor, and no pane left for it. before = serials() -- cgit v1.3