diff --git a/.crumb b/.crumb index 0361ac69b..fbf9f8206 100644 --- a/.crumb +++ b/.crumb @@ -87,14 +87,14 @@ "purpose": "Directory spec. Purpose not yet described by a human." }, { - "digest": "6f2382aa4a43051c056432af6ef420b1b85ed6988c2f9ca4de373033eccd816b", - "last_commit": "1e8614cc", + "digest": "8379cb7322fcc5ebb6053b520eeb441d78497389d692153a9d24e5f5bc6e62fa", + "last_commit": "5503cc2c", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, { - "digest": "3b456bbcc69519f5fface865e59242df8da23d6b11fd457d2e94529e832bdf57", - "last_commit": "1e8614cc", + "digest": "af422cd2fc56b4bd0379689500fd28602449f85b9d8e2a0497aee39977d0d91e", + "last_commit": "5503cc2c", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." }, @@ -105,15 +105,15 @@ "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:a2e005018652233722224251b5d18bacc3fcd968169828c643c9b047960c4ae3", - "compiled_at": "2026-10-10T07:24:11Z", + "children_root": "sha256:6b1d51c1c03faeafe9995d138f7d871c2dc9599a4eb1c6bbac5a1885a0bb73a9", + "compiled_at": "2026-10-10T07:35:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:c5dffbd9f2e9790e212078a6cf0749c3b0100065a604f162574ac085380d3731", + "digest": "sha256:3c7bc245fc5a684091e0bf3ddc09983137031f7f4d2435659948d9052131e022", "evidence_files": 6829, "evidence_root": "sha256:d430e46c9eac00396e5c58c2c8e60eb961500973312cc5eee25cf9d37e75bea2", "files": 9236, - "generated_at_commit": "1e8614cc3a570e6e626400147489f669d5fba455", - "source_tree": "sha256:b158053e61dcafea03696d2a5b4c576015614ebc648a986c2d95e4d9b9c2ca18" + "generated_at_commit": "5503cc2c90f6154a7a6f191d39e081f63b728669", + "source_tree": "sha256:beb8771d7aae4a2789da8907acad04ffc091f465af3ba06f073a43ae6ad6ba25" }, "owner_lane": "", "provenance": { diff --git a/src/.crumb b/src/.crumb index 07c953f94..320f372ff 100644 --- a/src/.crumb +++ b/src/.crumb @@ -115,8 +115,8 @@ "purpose": "Directory src/language. Purpose not yet described by a human." }, { - "digest": "098b6c8811fb0917f1de003d48b0b25d695e7d7a41418605b55ef44320d91c09", - "last_commit": "1e8614cc", + "digest": "93c5e6270b680c1aef7e311adc56fed4942f41db16d21108af4703e1e323b3d5", + "last_commit": "5503cc2c", "name": "osh", "purpose": "osh (Omega-native shell, arch#158) lexer unit: layout list, generator, osh_lex.osc, C reference " }, @@ -175,15 +175,15 @@ "purpose": "Directory src/visor. Purpose not yet described by a human." } ], - "children_root": "sha256:8a164931ea5b78a8824b25f26ab37eda9672423486f4ed4d4459f8617c3498a2", - "compiled_at": "2026-10-10T07:24:11Z", + "children_root": "sha256:ee7444d0238f1b94cc0fc32388d8514f5212e265247b084b912d0f68eaa6c348", + "compiled_at": "2026-10-10T07:35:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:6f2382aa4a43051c056432af6ef420b1b85ed6988c2f9ca4de373033eccd816b", + "digest": "sha256:8379cb7322fcc5ebb6053b520eeb441d78497389d692153a9d24e5f5bc6e62fa", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 445, - "generated_at_commit": "1e8614cc3a570e6e626400147489f669d5fba455", - "source_tree": "sha256:cf056f13995c596df4b36479ab7d95641e43fe84a0fda01e58b6f548f7e85f66" + "generated_at_commit": "5503cc2c90f6154a7a6f191d39e081f63b728669", + "source_tree": "sha256:fb059cf960d99aee3f406c6418c7f9292db626309773349f72941358548c9efa" }, "owner_lane": "", "provenance": { diff --git a/src/osh/.crumb b/src/osh/.crumb index 77319c7a3..4c3433b6c 100644 --- a/src/osh/.crumb +++ b/src/osh/.crumb @@ -3,21 +3,21 @@ "generated": { "children": [ { - "digest": "15ce5cb71c0547b717abce36dff3c63c29b6766b23ef806e7935045ca7d603d7", - "last_commit": "1e8614cc", + "digest": "59c39a686b6d2ed147d462e7bd2836de719d54886b10ee285d86fb5db53f7453", + "last_commit": "5503cc2c", "name": "host", "purpose": "osh Linux host: execution service (request decoder, resolution, builtins, redirections, pipeline" } ], - "children_root": "sha256:cf4e92d998888dd79e8eec2ed0e3b1730eea823995e985aada3228620dc4b854", - "compiled_at": "2026-10-10T07:24:11Z", + "children_root": "sha256:9943bf9a0ecc2d5b20be13b8ae1513e0507802b4986c5b98a4f864e4e9f0d46f", + "compiled_at": "2026-10-10T07:35:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:098b6c8811fb0917f1de003d48b0b25d695e7d7a41418605b55ef44320d91c09", + "digest": "sha256:93c5e6270b680c1aef7e311adc56fed4942f41db16d21108af4703e1e323b3d5", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 31, - "generated_at_commit": "1e8614cc3a570e6e626400147489f669d5fba455", - "source_tree": "sha256:0c2a3abb95e2f09be421278a6736067337ddf04e1c37153748ed829aa618af6f" + "generated_at_commit": "5503cc2c90f6154a7a6f191d39e081f63b728669", + "source_tree": "sha256:29abf5c74c53a12fda5496bbf1cb22873c54a2088949ba2ec4c22c4efcb56db5" } }, "name": "osh", diff --git a/src/osh/host/.crumb b/src/osh/host/.crumb index 63044a9a2..e87600e31 100644 --- a/src/osh/host/.crumb +++ b/src/osh/host/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-10T07:24:11Z", + "compiled_at": "2026-10-10T07:35:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:15ce5cb71c0547b717abce36dff3c63c29b6766b23ef806e7935045ca7d603d7", + "digest": "sha256:59c39a686b6d2ed147d462e7bd2836de719d54886b10ee285d86fb5db53f7453", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 16, - "generated_at_commit": "1e8614cc3a570e6e626400147489f669d5fba455", - "source_tree": "sha256:a9648776cf471738c88903f519845bf1105765646384b6131d8a6ea265f48b91" + "generated_at_commit": "5503cc2c90f6154a7a6f191d39e081f63b728669", + "source_tree": "sha256:41d4638f591f65202b2cc6eb123c9c9d93b53002b869388a7cd552c44c9068d5" } }, "name": "host", diff --git a/src/osh/host/osh_builtin.c b/src/osh/host/osh_builtin.c index 849ee86f7..238759d9e 100644 --- a/src/osh/host/osh_builtin.c +++ b/src/osh/host/osh_builtin.c @@ -328,11 +328,61 @@ static int cmp_var(const void *a, const void *b) return strcmp((*(const OshVar *const *)a)->name, (*(const OshVar *const *)b)->name); } +/* `declare -x NAME="value"` quoting as bash 5.2 prints it: double quotes with \ before " \ $ `; when the value holds + * a control or non-ASCII byte, the $'...' form with \a \b \t \n \v \f \r \E, \\ \' and three-digit octal otherwise. */ +static void out_declare_value(Out *o, const char *v) +{ + int ansi = 0; + for (const unsigned char *q = (const unsigned char *)v; *q; q++) + if (*q < 0x20 || *q >= 0x7f) { ansi = 1; break; } + if (!ansi) { + out_bytes(o, "\"", 1); + for (const char *q = v; *q; q++) { + if (*q == '"' || *q == '\\' || *q == '$' || *q == '`') out_bytes(o, "\\", 1); + out_bytes(o, q, 1); + } + out_bytes(o, "\"", 1); + return; + } + out_bytes(o, "$'", 2); + for (const unsigned char *q = (const unsigned char *)v; *q; q++) { + const char *esc = NULL; + switch (*q) { + case '\a': esc = "\\a"; break; case '\b': esc = "\\b"; break; case '\t': esc = "\\t"; break; + case '\n': esc = "\\n"; break; case '\v': esc = "\\v"; break; case '\f': esc = "\\f"; break; + case '\r': esc = "\\r"; break; case 0x1b: esc = "\\E"; break; + case '\\': esc = "\\\\"; break; case '\'': esc = "\\'"; break; + } + if (esc) { out_bytes(o, esc, strlen(esc)); continue; } + if (*q < 0x20 || *q >= 0x7f) { + char oct[5]; + snprintf(oct, sizeof oct, "\\%03o", *q); + out_bytes(o, oct, 4); + continue; + } + out_bytes(o, (const char *)q, 1); + } + out_bytes(o, "'", 1); +} + +/* export [-fn] [name[=value] ...] | export -p (bash 5.2 shape, #344 RISK-6) + * -p with no names lists `declare -x` lines sorted by name; -p with names is a plain export and prints nothing. + * -n assigns NAME=value if given, then drops the export mark but keeps the variable. -f names functions, which osh + * does not have, so every -f name is "not a function" (status 1). An unknown option is status 2 with the usage line. */ static int bi_export(OshSession *s, const OshCmd *c, const int io[3]) { - int i = 1, status = 0; - if (i < c->nargv && strcmp(c->argv[i], "--") == 0) i++; - if (i < c->nargv && strcmp(c->argv[i], "-p") == 0 && i + 1 == c->nargv) i++; + int i = 1, status = 0, unexport = 0, fn = 0; + for (; i < c->nargv && c->argv[i][0] == '-' && c->argv[i][1]; i++) { + if (strcmp(c->argv[i], "--") == 0) { i++; break; } + for (const char *p = c->argv[i] + 1; *p; p++) { + if (*p == 'n') unexport = 1; + else if (*p == 'f') fn = 1; + else if (*p != 'p') { + osh_diag(io[2], "export: -%c: invalid option\nexport: usage: export [-fn] [name[=value] ...] or export -p", *p); + return 2; + } + } + } if (i >= c->nargv) { const OshVar **v = malloc((s->nvars + 1) * sizeof *v); if (!v) return 1; @@ -342,16 +392,9 @@ static int bi_export(OshSession *s, const OshCmd *c, const int io[3]) qsort(v, n, sizeof *v, cmp_var); Out o = {.fd = io[1]}; for (size_t k = 0; k < n; k++) { - out_bytes(&o, "export ", 7); + out_bytes(&o, "declare -x ", 11); out_bytes(&o, v[k]->name, strlen(v[k]->name)); - if (v[k]->value) { - out_bytes(&o, "='", 2); - for (const char *q = v[k]->value; *q; q++) { - if (*q == '\'') out_bytes(&o, "'\\''", 4); - else out_bytes(&o, q, 1); - } - out_bytes(&o, "'", 1); - } + if (v[k]->value) { out_bytes(&o, "=", 1); out_declare_value(&o, v[k]->value); } out_bytes(&o, "\n", 1); } out_flush(&o); @@ -362,11 +405,15 @@ static int bi_export(OshSession *s, const OshCmd *c, const int io[3]) const char *a = c->argv[i], *eq = strchr(a, '='); char name[256]; size_t nl = eq ? (size_t)(eq - a) : strlen(a); + if (fn) { osh_diag(io[2], "export: %s: not a function", a); status = 1; continue; } if (nl == 0 || nl >= sizeof name) { osh_diag(io[2], "export: '%s': not a valid identifier", a); status = 1; continue; } memcpy(name, a, nl); name[nl] = 0; if (!osh_name_valid(name)) { osh_diag(io[2], "export: '%s': not a valid identifier", a); status = 1; continue; } - if (osh_var_export(s, name, eq ? eq + 1 : NULL)) { osh_diag(io[2], "export: out of memory"); status = 1; } + if (unexport) { + if (eq && osh_var_set(s, name, eq + 1)) { osh_diag(io[2], "export: out of memory"); status = 1; continue; } + osh_var_unexport(s, name); + } else if (osh_var_export(s, name, eq ? eq + 1 : NULL)) { osh_diag(io[2], "export: out of memory"); status = 1; } } return status; } diff --git a/src/osh/host/osh_host.h b/src/osh/host/osh_host.h index bf35c36d2..1239196e0 100644 --- a/src/osh/host/osh_host.h +++ b/src/osh/host/osh_host.h @@ -161,6 +161,7 @@ void osh_session_free(OshSession *s); const char *osh_var_get(const OshSession *s, const char *name); /* NULL if unset */ int osh_var_set(OshSession *s, const char *name, const char *value); /* keeps export flag; 0 ok, -1 invalid/oom */ int osh_var_export(OshSession *s, const char *name, const char *value_or_null); +int osh_var_unexport(OshSession *s, const char *name); /* keeps the variable, drops the export mark */ int osh_var_unset(OshSession *s, const char *name); int osh_name_valid(const char *s); char **osh_build_envp(const OshSession *s, const OshAssign *ov, int nov); /* malloc'd, free with osh_envp_free */ diff --git a/src/osh/host/osh_vars.c b/src/osh/host/osh_vars.c index 5aad4504b..c0f860f80 100644 --- a/src/osh/host/osh_vars.c +++ b/src/osh/host/osh_vars.c @@ -71,6 +71,13 @@ int osh_var_export(OshSession *s, const char *name, const char *value) return 0; } +int osh_var_unexport(OshSession *s, const char *name) +{ + OshVar *v = find(s, name); + if (v) v->exported = 0; + return 0; /* bash: `export -n` of an unset name is a silent success */ +} + int osh_var_unset(OshSession *s, const char *name) { for (size_t i = 0; i < s->nvars; i++) diff --git a/tests/.crumb b/tests/.crumb index ea1b687a5..e8f1edf4a 100644 --- a/tests/.crumb +++ b/tests/.crumb @@ -199,8 +199,8 @@ "purpose": "Simulated M16 driver for numeric resource-lifecycle tests. No device execution or numeric parity" }, { - "digest": "15237aba0370ba7eb3befdb23addbcf9ecfbd47f7d7e4a518eadb0ebda39f33a", - "last_commit": "1e8614cc", + "digest": "c0d62dbbf30e78826e3b7bb57947454a6a62f87a3af37e54c9cc67e9fad5f409", + "last_commit": "5503cc2c", "name": "osh", "purpose": "osh lexer host driver, vendored aien-protocols PR#16 draft vectors (5ae5292)" }, @@ -289,15 +289,15 @@ "purpose": "Directory tests/visor. Purpose not yet described by a human." } ], - "children_root": "sha256:5e321e0cf0a6dd0324553624f8b148c7f827729f83b3a272f5c24fbb88ec0edc", - "compiled_at": "2026-10-10T07:24:11Z", + "children_root": "sha256:2fb52503bdfa2c6e412a51b31ec4ba70e304ad90d78e3ede91b04b32442b861a", + "compiled_at": "2026-10-10T07:35:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:3b456bbcc69519f5fface865e59242df8da23d6b11fd457d2e94529e832bdf57", + "digest": "sha256:af422cd2fc56b4bd0379689500fd28602449f85b9d8e2a0497aee39977d0d91e", "evidence_files": 11, "evidence_root": "sha256:d5c1bceb4d57ef0eb42797c58801b5926509711614c3e38bb7105b6efa3942f2", "files": 948, - "generated_at_commit": "1e8614cc3a570e6e626400147489f669d5fba455", - "source_tree": "sha256:b745c2ce00fcfcf01f5d7d882e5060946f0ff34d1694f46c5036d2015bafa6b2" + "generated_at_commit": "5503cc2c90f6154a7a6f191d39e081f63b728669", + "source_tree": "sha256:3f1a874529f064f2be86c711ef9e0e02b55f66af0b24333bb340ae6b05572bac" }, "owner_lane": "", "provenance": { diff --git a/tests/osh/.crumb b/tests/osh/.crumb index 820b1d698..f6b0cb3aa 100644 --- a/tests/osh/.crumb +++ b/tests/osh/.crumb @@ -9,8 +9,8 @@ "purpose": "end-to-end tests of the osh program: argprint helper plus a runner comparing native and OSH_INTE" }, { - "digest": "4e96eafa5d50a39c3bab64ba958c0f72df2172644e5bb022a1e43409dc36a149", - "last_commit": "1e8614cc", + "digest": "8541cc8e514c2e45b9dcf90300854e41c29faedea2fccc4fb26084ca97efe136", + "last_commit": "5503cc2c", "name": "host", "purpose": "tests for the osh Linux host adapter execution service (hand-built request records, helper-mode " }, @@ -21,15 +21,15 @@ "purpose": "Core-only step traces of the osh shell units over fixture scripts (OSH-AIENOS-0 differential fix" } ], - "children_root": "sha256:ff0187ef47106b27e7a54d87c9b5a643faddd20c5733f8c052e96712f973fa01", - "compiled_at": "2026-10-10T07:24:11Z", + "children_root": "sha256:5319bc087019becf6da3193bccf34fca5083663f77f282ff14e3e9236c724e1b", + "compiled_at": "2026-10-10T07:35:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:15237aba0370ba7eb3befdb23addbcf9ecfbd47f7d7e4a518eadb0ebda39f33a", + "digest": "sha256:c0d62dbbf30e78826e3b7bb57947454a6a62f87a3af37e54c9cc67e9fad5f409", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 93, - "generated_at_commit": "1e8614cc3a570e6e626400147489f669d5fba455", - "source_tree": "sha256:abfe52976d5e38390e59d12e50b30be34c8deeba14bfa31bf7c60dfb47be8e42" + "generated_at_commit": "5503cc2c90f6154a7a6f191d39e081f63b728669", + "source_tree": "sha256:a89fa817be2b33aef0942a199aacbcc2a9a04b975515016cfcf81e74f82944ef" } }, "name": "osh-tests", diff --git a/tests/osh/host/.crumb b/tests/osh/host/.crumb index 02d6f4905..02104d627 100644 --- a/tests/osh/host/.crumb +++ b/tests/osh/host/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-10T07:24:11Z", + "compiled_at": "2026-10-10T07:35:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:4e96eafa5d50a39c3bab64ba958c0f72df2172644e5bb022a1e43409dc36a149", + "digest": "sha256:8541cc8e514c2e45b9dcf90300854e41c29faedea2fccc4fb26084ca97efe136", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 3, - "generated_at_commit": "1e8614cc3a570e6e626400147489f669d5fba455", - "source_tree": "sha256:05bb9f92feb9134e74b7727ddaf110a6357d7cb139a636788217c8ad727a088b" + "generated_at_commit": "5503cc2c90f6154a7a6f191d39e081f63b728669", + "source_tree": "sha256:70c4774cb969d11c064e5e3e16e14a99e8571b97c1a28cbad4e36898d64ae592" } }, "name": "host-tests", diff --git a/tests/osh/host/test_osh_host.c b/tests/osh/host/test_osh_host.c index 96a4e3d2f..4a0a0c1c0 100644 --- a/tests/osh/host/test_osh_host.c +++ b/tests/osh/host/test_osh_host.c @@ -553,7 +553,81 @@ static void test_builtins(void) CHECK(strcmp(o, "\n") == 0, "unset reaches children, got '%s'", o); free(o); + /* export -p / -n / -f / bad option, measured against bash 5.2.21 (#344 RISK-6) */ + osh_var_export(&t.s, "XQ", "a$b\"c\\d`e"); /* double-quote form escapes \" \\ $ ` */ + osh_var_export(&t.s, "XT", "x\ty'z\001\177\200"); /* control or non-ASCII bytes: $'...' form */ + osh_var_export(&t.s, "XE", ""); + t_clear(&t); + b = nb(0, 0); + cmd(b, OSH_B_EXPORT, "export", "-p", NULL); + CHECK(go(&t, b, &r) == 0, "export -p status"); + o = t_out(&t); + CHECK(strstr(o, "declare -x XB\n") && strstr(o, "declare -x XC=\"3\"\n") && !strstr(o, "export "), "export -p uses declare -x lines, got '%s'", o); + CHECK(strstr(o, "declare -x XQ=\"a\\$b\\\"c\\\\d\\`e\"\n") != NULL, "export -p double-quote escaping, got '%s'", o); + CHECK(strstr(o, "declare -x XT=$'x\\ty\\'z\\001\\177\\200'\n") != NULL, "export -p $'...' form for control bytes, got '%s'", o); + CHECK(strstr(o, "declare -x XE=\"\"\n") != NULL, "export -p empty value, got '%s'", o); + free(o); + t_clear(&t); + b = nb(0, 0); + cmd(b, OSH_B_EXPORT, "export", "-pn", NULL); /* options with no names still list */ + CHECK(go(&t, b, &r) == 0, "export -pn status"); + o = t_out(&t); + CHECK(strstr(o, "declare -x XC=\"3\"\n") != NULL, "export -pn lists, got '%s'", o); + free(o); + t_clear(&t); + b = nb(0, 0); + cmd(b, OSH_B_EXPORT, "export", "-n", "XC", "XN=7", "NOPE", NULL); /* -n keeps the variable, drops the export mark; assigns first */ + CHECK(go(&t, b, &r) == 0 && osh_var_get(&t.s, "XC") && strcmp(osh_var_get(&t.s, "XC"), "3") == 0, "export -n keeps value"); + CHECK(osh_var_get(&t.s, "XN") && strcmp(osh_var_get(&t.s, "XN"), "7") == 0, "export -n NAME=value assigns"); + t_clear(&t); + b = nb(0, 0); + helper(b, "env", "XC", NULL); + go(&t, b, &r); + b = nb(0, 0); + helper(b, "env", "XN", NULL); + go(&t, b, &r); + o = t_out(&t); + CHECK(strcmp(o, "\n\n") == 0, "export -n: children no longer see them, got '%s'", o); + free(o); + t_clear(&t); + b = nb(0, 0); + cmd(b, OSH_B_EXPORT, "export", "-p", "XC", NULL); /* -p with names is a plain export, prints nothing */ + CHECK(go(&t, b, &r) == 0, "export -p NAME status"); + o = t_out(&t); + CHECK(*o == 0, "export -p NAME prints nothing, got '%s'", o); + free(o); + t_clear(&t); + b = nb(0, 0); + helper(b, "env", "XC", NULL); + go(&t, b, &r); + o = t_out(&t); + CHECK(strcmp(o, "3\n") == 0, "export -p NAME re-exported, got '%s'", o); + free(o); + t_clear(&t); + b = nb(0, 0); + cmd(b, OSH_B_EXPORT, "export", "-q", "XC", NULL); + CHECK(go(&t, b, &r) == 2, "export bad option status 2"); + o = t_err(&t); + CHECK(strstr(o, "export: -q: invalid option") && strstr(o, "export: usage: export [-fn] [name[=value] ...] or export -p"), "export bad option diagnostic, got '%s'", o); + free(o); + t_clear(&t); + b = nb(0, 0); + cmd(b, OSH_B_EXPORT, "export", "-f", "zz", NULL); /* osh has no functions */ + CHECK(go(&t, b, &r) == 1, "export -f status 1"); + o = t_err(&t); + CHECK(strstr(o, "export: zz: not a function") != NULL, "export -f diagnostic, got '%s'", o); + free(o); + t_clear(&t); + b = nb(0, 0); + cmd(b, OSH_B_EXPORT, "export", "-", NULL); + CHECK(go(&t, b, &r) == 1, "export - is an invalid identifier"); + b = nb(0, 0); + cmd(b, OSH_B_EXPORT, "export", "--", "-n", NULL); + CHECK(go(&t, b, &r) == 1 && osh_var_get(&t.s, "XN") && strcmp(osh_var_get(&t.s, "XN"), "7") == 0, "export -- -n: -n is a (bad) name, not an option"); + t_clear(&t); + /* exit: parent only when alone */ + b = nb(0, 0); cmd(b, OSH_B_EXIT, "exit", "7", NULL); CHECK(go(&t, b, &r) == 7 && t.s.exit_requested && t.s.exit_status == 7 && r.exit_requested, "exit 7 in parent");