diff options
-rw-r--r-- | src/deps/zig-clap/clap/comptime.zig | 8 | ||||
-rw-r--r-- | test/apps/bun-run-check.sh | 23 |
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 |