code wiki / _hdl_build / nx_argecho.nx

nx_argecho.nx source

↩ module page · 16 lines · 542 B

1// nx_argecho.nx -- prints each argv entry on its own line. A test child for nx_run: proves args (including 2// ones with spaces, quotes, &, |, >) pass through VERBATIM -- the exact thing `sh -c` mangles. license_tier: ORIGINAL 3import "nx_syscalls.nx" 4 5func main(argc: i64, argv: *i64) -> i64 { 6 var i: i64 = 0 7 while i < argc { 8 let s: *u8 = argv[i] as *u8 9 var n: i64 = 0 10 while s[n] != (0 as u8) { n = n + 1 } 11 sys_write(1, s, n) 12 sys_write(1, "\n" as *u8, 1) 13 i = i + 1 14 } 15 return 0 16}