mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 20:39:05 +00:00
shell: implement $0, $1, argv accessors (#9740)
* shell: organize imports * shell: dont allocate when printing errors * shell: implement $0, $1, argv accessors * add more tests * oops need this commit too * make these logs listen to silencing logs * expand switch else statements * align behavior with bash * this isnt referenced anywhere * add missing test file * add another test * revert this change * cache utf8 converted version of positionals * rebase fixes --------- Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
This commit is contained in:
@@ -13,7 +13,7 @@ const open = @import("../open.zig");
|
||||
const Command = bun.CLI.Command;
|
||||
|
||||
pub const ExecCommand = struct {
|
||||
pub fn exec(ctx: Command.Context) !void {
|
||||
pub fn exec(ctx: *Command.Context) !void {
|
||||
const script = ctx.positionals[1];
|
||||
// this is a hack: make dummy bundler so we can use its `.runEnvLoader()` function to populate environment variables probably should split out the functionality
|
||||
var bundle = try bun.Bundler.init(
|
||||
@@ -39,7 +39,7 @@ pub const ExecCommand = struct {
|
||||
};
|
||||
const script_path = bun.path.join(parts, .auto);
|
||||
|
||||
const code = bun.shell.Interpreter.initAndRunFromSource(mini, script_path, script) catch |err| {
|
||||
const code = bun.shell.Interpreter.initAndRunFromSource(ctx, mini, script_path, script) catch |err| {
|
||||
Output.prettyErrorln("<r><red>error<r>: Failed to run script <b>{s}<r> due to error <b>{s}<r>", .{ script_path, @errorName(err) });
|
||||
Global.exit(1);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user