aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-22 01:56:07 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-22 01:56:07 -0700
commitf1ffc72a624a31c7c16d5daad28facd40c7f73e2 (patch)
treeb09da656531c8d901ce1a52bb9d96a39d2693205
parent37eee4235de88c708cdce1a200c39387da5bbee3 (diff)
downloadbun-f1ffc72a624a31c7c16d5daad28facd40c7f73e2.tar.gz
bun-f1ffc72a624a31c7c16d5daad28facd40c7f73e2.tar.zst
bun-f1ffc72a624a31c7c16d5daad28facd40c7f73e2.zip
Fix `bun run foo --` by ignoring `--`
-rw-r--r--src/deps/zig-clap/clap/comptime.zig8
-rw-r--r--test/apps/bun-run-check.sh23
2 files changed, 29 insertions, 2 deletions
diff --git a/src/deps/zig-clap/clap/comptime.zig b/src/deps/zig-clap/clap/comptime.zig
index 8bcb91cd3..e3b3a8cdc 100644
--- a/src/deps/zig-clap/clap/comptime.zig
+++ b/src/deps/zig-clap/clap/comptime.zig
@@ -81,9 +81,13 @@ pub fn ComptimeClap(
"TODO: implement stop_after_positional_at on windows",
);
- const remaining_ = std.os.argv[@minimum(std.os.argv.len, stream.iter.args.inner.index)..];
- try passthrough_positionals.ensureTotalCapacityPrecise(remaining_.len);
+ var remaining_ = std.os.argv[@minimum(std.os.argv.len, stream.iter.args.inner.index)..];
+ const first: []const u8 = if (remaining_.len > 0) bun.span(remaining_[0]) else "";
+ if (first.len > 0 and std.mem.eql(u8, first, "--")) {
+ remaining_ = remaining_[1..];
+ }
+ try passthrough_positionals.ensureTotalCapacityPrecise(remaining_.len);
for (remaining_) |arg_| {
// use bun.span due to the optimization for long strings
passthrough_positionals.appendAssumeCapacity(bun.span(arg_));
diff --git a/test/apps/bun-run-check.sh b/test/apps/bun-run-check.sh
index 3f54fa26b..25432c422 100644
--- a/test/apps/bun-run-check.sh
+++ b/test/apps/bun-run-check.sh
@@ -22,6 +22,18 @@ if (($?)); then
exit 1
fi
+# We need to run these tests for two variations:
+# bun run foo "bar"
+# bun run foo -- "bar"
+# the "--" should be ignored
+# in earlier versions of bun, it was required to be present
+
+$BUN_BIN run bash -c ""
+if (($?)); then
+ echo "Bash exported functions are broken"
+ exit 1
+fi
+
# https://github.com/oven-sh/bun/issues/53
rm -f /tmp/bun-run-out.expected.txt /tmp/bun-run-out.txt >/dev/null 2>&1
@@ -34,6 +46,17 @@ if (($?)); then
exit 1
fi
+rm -f /tmp/bun-run-out.expected.txt /tmp/bun-run-out.txt >/dev/null 2>&1
+
+$BUN_BIN run --silent argv foo bar baz >/tmp/bun-run-out.txt
+npm run --silent argv -- foo bar baz >/tmp/bun-run-out.expected.txt
+
+cmp -s /tmp/bun-run-out.expected.txt /tmp/bun-run-out.txt
+if (($?)); then
+ echo "argv failed"
+ exit 1
+fi
+
$BUN_BIN run --silent this-should-work
if (($?)); then