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/tests/osh/e2e/argprint.c # 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 / tests / osh / e2e / argprint.c` 59 lines ยท 2194 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 * argprint.c -- tiny helper program for the osh end-to-end tests (aien-architecture#158). Not part of osh. 19 * argprint ARGS... prints each argument as [arg] on its own line 20 * argprint -e NAME prints [value] of an environment variable, or [(unset)] 21 * argprint -x N exits with status N, printing nothing 22 * argprint -cat copies standard input to standard output 23 * argprint -io writes "O" to standard output and "E" to standard error, in that order 24 * argprint -pwd prints the current directory 25 */ 26 #include 27 #include 28 #include 29 #include 30 31 int main(int argc, char **argv) 32 { 33 if (argc >= 3 && strcmp(argv[1], "-e") == 0) { 34 const char *v = getenv(argv[2]); 35 printf("[%s]\n", v ? v : "(unset)"); 36 return 0; 37 } 38 if (argc >= 3 && strcmp(argv[1], "-x") == 0) return atoi(argv[2]); 39 if (argc == 2 && strcmp(argv[1], "-cat") == 0) { 40 char b[4096]; 41 ssize_t r; 42 while ((r = read(0, b, sizeof b)) > 0) 43 if (write(1, b, (size_t)r) != r) return 1; 44 return 0; 45 } 46 if (argc == 2 && strcmp(argv[1], "-io") == 0) { 47 if (write(1, "O", 1) != 1) return 1; 48 if (write(2, "E", 1) != 1) return 1; 49 return 0; 50 } 51 if (argc == 2 && strcmp(argv[1], "-pwd") == 0) { 52 char b[4096]; 53 if (!getcwd(b, sizeof b)) return 1; 54 printf("[%s]\n", b); 55 return 0; 56 } 57 for (int i = 1; i < argc; i++) printf("[%s]\n", argv[i]); 58 return 0; 59 }