commit 7b2866d036812a92ad614f5d9b98cac26dc1303c parent 8c71e3535fcf4a64c33ece2b8d7f8c61718689ae Author: Drew DeVault <sir@cmpwn.com> Date: Sat, 30 Jan 2021 15:03:45 -0500 os: implement os::args Diffstat:
A | os/+linux/environ.ha | | | 19 | +++++++++++++++++++ |
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/os/+linux/environ.ha b/os/+linux/environ.ha @@ -0,0 +1,19 @@ +use rt; +use strings; +use types; + +// The command line arguments provided to the program. By convention, the first +// member is usually the name of the program. +export let args: []str = []; + +@init fn init() void = { + args = alloc([]str, [], rt::argc); + (&args: *types::slice).length = rt::argc; // HORRIBLE HACK + for (let i = 0z; i < rt::argc; i += 1z) { + args[i] = strings::from_c(rt::argv[i]); + }; +}; + +@fini fn fini() void = { + free(args); +};