diff options
| author | user <user@clank> | 2026-08-26 16:11:42 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-26 16:11:42 +0200 |
| commit | 087b2bd1d31dac24f8b0ffe79c33f4ebf1f60bd3 (patch) | |
| tree | 282ce9a0e243333bb769bae231426cb4f9cf3a86 /contrib | |
| parent | compact: shared borders instead of gaps (D23) (diff) | |
| download | slosh-087b2bd1d31dac24f8b0ffe79c33f4ebf1f60bd3.tar.gz slosh-087b2bd1d31dac24f8b0ffe79c33f4ebf1f60bd3.tar.xz slosh-087b2bd1d31dac24f8b0ffe79c33f4ebf1f60bd3.zip | |
macos: the kernel still knows, it just spells /proc differently
Portability fixes contributed by our macOS developer, applied with one
hardening tweak (below).
Darwin has no /proc, so everything that read one gets the native answer:
live_cwd via proc_pidinfo(PROC_PIDVNODEPATHINFO), the foreground command
via sysctl(KERN_PROCARGS2) parsed back into the NUL-separated shape
/proc/<pid>/cmdline gives, and SLOSH_BIN via _NSGetExecutablePath plus
realpath. The pty gets its winsize set on the slave after opening it,
because Darwin attaches no line discipline to the master until then and
the earlier TIOCSWINSZ was silently dropped -- a pane born 0x0. The
shader repl binds tab in libedit's own words, since macOS ships Python's
readline as a libedit wrapper that accepts GNU syntax in silence.
Two finds are cross-platform bugs: a toast wider than the screen minus
the gap computed a negative x that uint16_t made ~65533, drawing the
longest messages -- the ones most worth reading -- off screen; now the
middle is elided (a path's tail is the half you needed) and x clamps.
And a pane label was 128 bytes, which a Homebrew interpreter's full path
exceeds before its arguments even start; dump-layout wrote the
truncation down and a restore ran it, so it is 1024 now.
Saving a layout learned cwd_as_named: the kernel answers with the
physical path, and on macOS /tmp is a symlink to /private/tmp, so a
layout that said cwd="/tmp" stopped round-tripping through a save.
If realpath(named) is where the pane still is, the named spelling wins.
Tests follow: realpath'd tmpdirs, the scroll test reads the shell's
first prompt instead of spelling out bash 5.3, and wrapped pane text is
joined before matching a long path.
One tweak on top of the contribution: the elision needs five columns
for a head, the dots and a tail -- below that `avail - 3` goes
negative, and negative as size_t is a pointer into the weeds; a
terminal that narrow gets a plain clip.
Diffstat (limited to 'contrib')
| -rwxr-xr-x | contrib/shader-repl | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/contrib/shader-repl b/contrib/shader-repl index c0ff216..810c556 100755 --- a/contrib/shader-repl +++ b/contrib/shader-repl @@ -202,7 +202,13 @@ def setup_readline(): # `=`, `"` and `(` end a word: `color="#ff` should complete on `#ff`, and # `clamp(23` should not look like one enormous token. readline.set_completer_delims(' \t\n;=("') - readline.parse_and_bind("tab: complete") + # macOS ships Python's readline as a libedit wrapper, and libedit does not + # speak GNU readline's binding syntax: "tab: complete" is accepted in + # silence and tab does nothing at all. Same intent, its own words. + if "libedit" in (readline.__doc__ or ""): + readline.parse_and_bind("bind ^I rl_complete") + else: + readline.parse_and_bind("tab: complete") def write_history(): |
