code wiki / (root) / nx_shell_lib.nx

nx_shell_lib.nx

buildroot/runtime/nx_shell_lib.nx

9011 B166 linesdepth 3pulls 4 transitivereach 2 importersview sourcekind librarytopic shell
docsdependenciesstructsconstsfunctions

about

nx_shell_lib.nx -- GENERAL SOVEREIGN SHELL CAPABILITY (the shared library for the Nishi shell toolchain). Extracted (rule 15) so the gate (nx_shell) and the drivable tool (nx_shell_run) share ONE capability, not copies. Pure library: no main. Imports only nx_syscalls (the kernel last-mile). NEVER-BRICK: spawns userspace, writes 0 persistent hardware state -> brick-safe by construction (cardinal 26). UI g_puts/g_pn STR sh_slen/sh_streq R1 sh_tokenize (command line -> argv) R3 sh_builtin (echo/cd/true/false in-process) R4 sh_grep (substring) / sh_grep_stream (pipeline filter: fd0->fd1) / sh_run_capture (pipe-capture) R2 sh_run (fork+execve+wait) / sh_exec_one (builtin-or-exec one command) R5 sh_split_ops / sh_exec_line (; && ||) R6/full sh_split_pipe / sh_stage_exec / sh_run_pipeline (N-stage |) / sh_exec_full (pipelines + control)

dependencies 3 imports · 2 importers

nx_syscalls.nx nx_itoa_lib.nx nx_regex_lib.nx nx_shell_lib.nx nx_shell.nx nx_shell_run.nx

imports: nx_syscalls.nxnx_itoa_lib.nxnx_regex_lib.nx

imported by: nx_shell.nxnx_shell_run.nx

structs

none

consts

16const K_MAGIC_65536: i64 = 65536

functions

18func g_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
23func g_pn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 2: mainmain calls 1: nxi_out
24func sh_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: sh_grep
25func sh_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8) { if a[i]!=b[i] { return 0 } i=i+1 } if b[i]==(0 as u8) { return 1 } return 0 }
27func sh_tokenize(line: *u8, copy: *u8, argv: *i64, maxtok: i64) -> i64
38func sh_builtin(argv: *i64, argc: i64) -> i64
48func sh_grep(buf: *u8, n: i64, needle: *u8) -> i64 { if sh_slen(needle)==0 { return 0 } return re_search(needle, buf, n) }
called by 2: mainsh_grep_stream calls 2: sh_slenre_search
49func sh_grep_stream(pattern: *u8) -> i64
61func sh_run(path: *u8, argv: *i64) -> i64
66func sh_run_capture(path: *u8, argv: *i64, out: *u8, cap: i64) -> i64
77func sh_exec_one(cmdline: *u8) -> i64
86func sh_split_ops(line: *u8, copy: *u8, segp: *i64, sego: *i64, maxseg: i64) -> i64
98func sh_exec_line(line: *u8) -> i64
113func sh_split_pipe(line: *u8, copy: *u8, stages: *i64, maxst: i64) -> i64
called by 1: sh_run_pipeline
120func sh_stage_exec(stage_line: *u8) -> i64
129func sh_run_pipeline(segment: *u8) -> i64
154func sh_exec_full(line: *u8) -> i64