diff --git a/src/shell/interpreter.zig b/src/shell/interpreter.zig index a1b62bddb1..f4264570f0 100644 --- a/src/shell/interpreter.zig +++ b/src/shell/interpreter.zig @@ -63,7 +63,8 @@ pub fn OOM(e: anyerror) noreturn { bun.outOfMemory(); } -const log = bun.Output.scoped(.SHELL, false); +const logscope = bun.Output.Scoped(.SHELL, false); +const log = logscope.log; const assert = bun.assert; @@ -1298,6 +1299,19 @@ pub const Interpreter = struct { break :brk lexer.get_result(); }; + if (bun.Environment.enable_logs and logscope.isVisible()) { + var log_buf = std.ArrayList(u8).init(arena_allocator); + defer log_buf.deinit(); + try log_buf.append('['); + for (lex_result.tokens, 0..) |token, i| { + if (i != 0) try log_buf.appendSlice(", "); + const tok_str = token.asHumanReadable(lex_result.strpool); + try log_buf.writer().print("\"{}\"", .{if (@hasDecl(bun.strings, "formatEscapes")) bun.strings.formatEscapes(tok_str, .{ .quote_char = '"' }) else bun.strings.QuoteEscapeFormat{ .data = tok_str }}); + } + try log_buf.append(']'); + logscope.log("Shell command tokens: {s}", .{log_buf.items}); + } + if (lex_result.errors.len > 0) { out_lex_result.* = lex_result; return shell.ParseError.Lex;