Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/src/osh/host/osh_shell.h # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / osh / host / osh_shell.h` 59 lines ยท 2674 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* 18 * osh_shell.h -- the osh driver loop (aien-architecture#158): feeds input lines to the lexer, parser and expander units, 19 * answers the expander's variable questions from the session, and hands each finished pipeline record to the host 20 * execution service. Host code is replaceable scaffolding (ADR 0024); it never tokenizes, parses or expands. 21 */ 22 #ifndef OSH_SHELL_H 23 #define OSH_SHELL_H 24 #include 25 #include 26 27 #include "osh_core.h" 28 #include "osh_host.h" 29 30 typedef struct { 31 OshCore core; 32 OshSession s; 33 int native; /* 1 native AArch64 units, 0 interpreter (OSH_INTERP=1) */ 34 int interactive; /* prompts and error recovery */ 35 char *arg0; /* $0 */ 36 char **pos; /* $1.. */ 37 int npos; 38 uint64_t *w; /* the workspace */ 39 uint8_t *buf; /* bytes of the list in progress */ 40 size_t blen, bcap; 41 unsigned long lists, refused; 42 } OshShell; 43 44 /* Compile the units (embedded sources) and set up the session from envp. 0 ok, else -1 with a message on stderr. */ 45 int osh_shell_init(OshShell *sh, char *const *envp, int native, int interactive, const char *arg0, char **pos, int npos); 46 void osh_shell_free(OshShell *sh); 47 48 /* Run a -c string from memory: a last line with no newline is ended by end of input itself (bash -c 49 * 'echo a\' prints a\). Returns the shell's exit status. */ 50 int osh_shell_run_string(OshShell *sh, const char *text, size_t len); 51 /* Run a script file's text from memory: a last line with no newline gets one, as from a file or pipe. */ 52 int osh_shell_run_script(OshShell *sh, const char *text, size_t len); 53 /* Run commands read from fd, one byte at a time so children inherit the unread rest. Returns the exit status. */ 54 int osh_shell_run_fd(OshShell *sh, int fd); 55 56 /* the three unit sources, embedded at build time (build/osh/osh_units.c) */ 57 extern const unsigned char osh_unit_lex[], osh_unit_parse[], osh_unit_expand[]; 58 extern const size_t osh_unit_lex_len, osh_unit_parse_len, osh_unit_expand_len; 59 #endif