summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 04:58:25 -0300
committerGabriel Schneider <[email protected]>2026-10-01 04:58:26 -0300
commit36fe45e3a4a7ce9b61ab7bf2df07f0132a9170c1 (patch)
tree7c2dd36427e170e05b880666b2c8f5f3d4f108d5
parent0c3cf0628adf9e22270b09d9c451b08ac07f558a (diff)
downloadpardes-36fe45e3a4a7ce9b61ab7bf2df07f0132a9170c1.tar.gz
pardes-36fe45e3a4a7ce9b61ab7bf2df07f0132a9170c1.zip
`--` ends pardes's options: `pardes -- -dash.txt` opens the file named -dash.txt
It said `no such option: --`. What follows `--` is a name, one at most, as for any other positional. Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--src/main.zig9
-rw-r--r--test/fs.py9
2 files changed, 18 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index de501047..a7d354b5 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -520,6 +520,15 @@ fn nativeMain(init: std.process.Init) !void {
} else if (std.mem.eql(u8, a, "--version")) {
try std.Io.File.stdout().writeStreamingAll(init.io, version_text);
return;
+ } else if (std.mem.eql(u8, a, "--")) {
+ // The end of options: what follows is a name, `-dash.txt` too.
+ for (args[i + 1 ..]) |name| {
+ if (name.len == 0) badArgs(init.io, "an empty argument names nothing", .{});
+ if (positional != null) badArgs(init.io, "one file or directory at a time, and '{s}' is the second", .{name});
+ session_only = false;
+ positional = name;
+ }
+ break;
} else if (a.len > 0 and (a[0] != '-' or std.mem.eql(u8, a, "-")) and positional == null) {
// `-` is stdin, as for cat and vim: a text to show.
session_only = false;
diff --git a/test/fs.py b/test/fs.py
index f24e2550..6c6bcbef 100644
--- a/test/fs.py
+++ b/test/fs.py
@@ -989,6 +989,7 @@ def test(binary, quic=False):
for options, message in [
(['--fs'], b'no such option'),
(['--fs9'], b'no such option'),
+ (['--', 'a', 'b'], b'is the second'),
(['--9p'], b'--9p needs a socket name'),
(['--9p='], b'invalid 9P socket name'),
(['--9p=a/b'], b'invalid 9P socket name'),
@@ -1396,6 +1397,14 @@ def test(binary, quic=False):
assert time.monotonic() - deleted < .05, time.monotonic() - deleted
assert second.wait(timeout=5) == 0
assert edited.read_bytes() == b'edited\n'
+ # `--` ends the options: a name starting with a dash is a name.
+ dash = root / '-dash.txt'
+ dash.write_bytes(b'dash\n')
+ before = serials()
+ assert subprocess.run([binary, '--', dash.name], cwd=root, env=env, capture_output=True, timeout=10).returncode == 0
+ dashed, = serials() - before
+ assert client.read(f'/pane/{dashed}/name').rstrip(b'\n') == str(dash).encode()
+ client.remove(f'/pane/{dashed}')
# --wait waits on the pane its look answered, on the look's own
# open: a name /index shows escaped (a backslash is `\\` there)
# is still the pane waited on, not one already gone.