const std = @import("std"); const Io = std.Io; pub fn main(init: std.process.Init) !void { // This is appropriate for anything that lives as long as the process. const arena: std.mem.Allocator = init.arena.allocator(); // Accessing command line arguments: const args = try init.minimal.args.toSlice(arena); const filepath = args[0]; const filename = std.fs.path.basename(filepath); std.log.debug("executable name: {s}", .{filename}); const io = init.io; var words = try tokenizeIntoArraylist(arena, filename); const command = try words.toOwnedSlice(arena); return std.process.replace(io, .{ .argv = command, }); } fn tokenizeIntoArraylist(gpa: std.mem.Allocator, buffer: []const u8) !std.ArrayList([]const u8) { var it = std.mem.tokenizeScalar(u8, buffer, ' '); var words = std.ArrayList([]const u8).empty; while (it.next()) |word| { try words.append(gpa, word); } return words; }