nx_shell_lib.nx
buildroot/runtime/nx_shell_lib.nx
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
imports: nx_syscalls.nxnx_itoa_lib.nxnx_regex_lib.nx
imported by: nx_shell.nxnx_shell_run.nx
structs
| none |
consts
| 16 | const K_MAGIC_65536: i64 = 65536 |
functions
| 18 | func 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 } |
| 23 | func g_pn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 24 | func 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 |
| 25 | func 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 } |
| 27 | func sh_tokenize(line: *u8, copy: *u8, argv: *i64, maxtok: i64) -> i64 |
| 38 | func sh_builtin(argv: *i64, argc: i64) -> i64 |
| 48 | func sh_grep(buf: *u8, n: i64, needle: *u8) -> i64 { if sh_slen(needle)==0 { return 0 } return re_search(needle, buf, n) } |
| 49 | func sh_grep_stream(pattern: *u8) -> i64 |
| 61 | func sh_run(path: *u8, argv: *i64) -> i64 |
| 66 | func sh_run_capture(path: *u8, argv: *i64, out: *u8, cap: i64) -> i64 |
| 77 | func sh_exec_one(cmdline: *u8) -> i64 |
| 86 | func sh_split_ops(line: *u8, copy: *u8, segp: *i64, sego: *i64, maxseg: i64) -> i64 |
| 98 | func sh_exec_line(line: *u8) -> i64 |
| 113 | func sh_split_pipe(line: *u8, copy: *u8, stages: *i64, maxst: i64) -> i64 called by 1: sh_run_pipeline |
| 120 | func sh_stage_exec(stage_line: *u8) -> i64 |
| 129 | func sh_run_pipeline(segment: *u8) -> i64 |
| 154 | func sh_exec_full(line: *u8) -> i64 |