summaryrefslogtreecommitdiffhomepage
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #52 from skurtz97/web/hero-comparisonHEADmainSean Kurtz7 hours2-17/+79
|\ | | | | web: update hero comparison and expand z/OS & Linux benchmarks
| * web: lead homepage benchmarks with z/OS and expand categoriesSean Kurtz7 hours1-7/+65
| | | | | | | | | | | | | | | | | | | | | | - Put the full z/OS benchmark table (21 categories against z/OS sh, bash, zsh, and oksh) first under 'How it compares' in web/content/_index.md, followed by the full Linux x86-64 table (23 categories against dash, bash, ksh93, and oksh). - All numbers are copied directly from README.md. Verified: - Built with hugo --source web --minify (0 errors) and verified live.
| * web: compare bash, /bin/sh, and zash on z/OS in hero showcaseSean Kurtz8 hours2-10/+14
|/ | | | | | | | | | | - Replace the 2-shell Linux dash/zash comparison in web/layouts/home.html with a 3-shell comparison (bash, /bin/sh, ./zash) measured on z/OS (37.12s vs 12.54s vs 0.01s for 10,000 command substitutions). - Trim the Korn features clause from section 02 in web/content/_index.md. Verified: - Measured all three shells directly on z/OS (10,000 iterations each). - Built with hugo --source web --minify (0 errors) and deployed live.
* Merge pull request #51 from skurtz97/release/0.5.0-betav0.5.0-betaSean Kurtz10 hours6-5/+16
|\ | | | | Prepare 0.5.0-beta release: remove host refs, add CI badge, update zopen buildenv
| * Keep ZOPEN_TYPE=LOCAL active by commenting ZOPEN_*_URL in buildenvSean Kurtz10 hours1-3/+4
| | | | | | | | | | zopen-build attempts a git clone whenever ZOPEN_DEV_URL is set, even with ZOPEN_TYPE=LOCAL. Keep the URLs commented until the repo is public.
| * Remove host-specific references, add CI badge, and prepare 0.5.0-beta zopen ↵Sean Kurtz10 hours6-5/+15
|/ | | | | | | | | | | buildenv - Remove internal z/OS test-host name from notes/review-2026-11-27.md, web/layouts/home.html, and tests/zos/zosvars.{sh,exp} (making zosvars portable to any z/OS LPAR by comparing against live ZOS_SYSNAME). - Add GitHub Actions CI status badge to README.md. - Bump buildenv version to 0.5.0 with ZOPEN_STABLE_URL, ZOPEN_STABLE_TAG (v0.5.0-beta), ZOPEN_DEV_URL, and explicit empty ZOPEN_RUNTIME_DEPS.
* Merge pull request #50 from skurtz97/ci/packaging-and-github-actionsSean Kurtz10 hours5-8/+71
|\ | | | | Add GitHub Actions Linux CI and fix zopen packaging checks
| * Record waited job status in reaped_list before freeing in builtin_waitSean Kurtz12 hours1-1/+3
| | | | | | | | | | | | | | | | When 'wait pid' waits directly on a still-running job rather than reading an already-reaped entry, record its pid and status via reaped_add() before calling job_free(), matching jobs_reap(), bash, and dash. Fixes intermittent 'again: 127' failures in tests/posix/wait-reap on busy z/OS hosts when 'false &' takes >0.3s.
| * Fix ASan runtime package in CI and keep buildenv deps to make + gzipSean Kurtz12 hours2-5/+6
| | | | | | | | | | | | | | - Install libclang-rt-19-dev with clang-19 in .github/workflows/ci.yml so make asan links libclang_rt.asan on ubuntu-24.04. - Keep ZOPEN_DEV_DEPS/ZOPEN_STABLE_DEPS to 'make gzip' so zopen coreutils' altbin does not shadow EBCDIC /bin/cat during zos/tagging.
| * Fix zopen packaging checks, update i-dscomplete.exp, and add GitHub Actions CISean Kurtz12 hours4-7/+67
|/ | | | | | | | | | | | | | - buildenv: declare coreutils, diffutils, and gzip in ZOPEN_DEV_DEPS and ZOPEN_STABLE_DEPS (build/check deps only; no runtime deps added) so tests/run.sh and tests/zos/tagging.sh have GNU tools and gzip under zopen build's minimal check environment. - tests/run.sh: unset _TAG_REDIR_IN, _TAG_REDIR_OUT, and _TAG_REDIR_ERR alongside _BPX_SHAREAS/_BPX_SPAWN_SCRIPT so zopen's check_clang env does not alter the tagging test baseline. - tests/linux/i-dscomplete.exp: update expected listing for CSI_MAX_CALLS=3 (changed from 2 to 3 in b3879f5 without regenerating .exp). - .github/workflows/ci.yml: add Linux CI workflow (Clang 19+, make, make zos-lint, make check, make asan, staged make install).
* Merge pull request #49 from skurtz97/fix/audit-2026-11-28Sean Kurtz13 hours23-108/+494
|\ | | | | Fix code audit findings across z/OS layer, parser, redirections, and builtins
| * Add regression tests for audit fixes and clear clang-tidy findingsSean Kurtz25 hours6-13/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | - Add tests/zash/audit-fixes.{sh,exp} covering uppercase bases, closed-fd duplication, [[ ... ]] and nested here-docs, quoted braces, 'for x; in', environment deduplication, PS4 expansion, pure subshell write errors, pipeline unwind loop_depth, 'set +o', POSIX 1-4 arg test rules, print -u bounds, whence -p, printf overflow and bare %b NULs, time/select keywords, '--' handling, unalias -- -a, kill --, and read -t 0. - Clear remaining clang-tidy warnings on changed lines in edit_builtin.c, sys_posix.c, test.c, and var.c. Verified on Linux (./zash and ./zash-asan); z/OS CBT verification next.
| * Fix builtin, signal, test, printf, option, and job-control bugsSean Kurtz25 hours8-54/+167
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Skip startup-only options in options_print() for 'set +o'. - Preserve ignored SIGINT traps in trap_reset_child()/trap_reset_exec(), rescan signals from 1 on trap_poll() unwind, and accept '--' after the signal operand in kill. - Implement POSIX 1-4 argument test/[ rules and bound-check -t fds. - Bound-check 'print -u' against SYS_NFD and require regular files in 'whence -p' with '/'. - Report ERANGE overflow in printf integer/float conversions and preserve embedded NUL bytes in bare %b. - Use exc_catch() in builtin_cd_isolated(), check sys_dupfd() in '.', include time/select in is_keyword(), poll with timeout 0 for 'read -t 0', accept '--' in eval/export/readonly/umask/unalias/wait/fg/bg, return on trapped signal during operand wait, and reap jobs in fg/bg. Verified locally on Linux (make, make zos-lint, make check: 128/129 pass).
| * Fix redirection, parser, arithmetic, environment, and exec bugsSean Kurtz25 hours5-23/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Fail cleanly in save_fd() when sys_dupfd() fails with errno != EBADF, check moved < 0 in plan_redirs()/plan_apply(), and reject duplicating from closed descriptors in plan_redirs(). - Accept uppercase digits in parse_based() for bases <= 36 while keeping ksh case-sensitive digits for bases 37..64. - Save and restore in_cond, alias_ended_blank, and here_head/here_tail in parse_cmdsub() and parse_substring(); parse inner double quotes inside "${x:-...}" via read_double_quoted(); reject 'for x; in ...'. - Deduplicate repeated temporary assignments in var_environ_with(). - Use access(X_OK) in path_search(), expand PS4 in xtrace() with recursion guarded, report stdout write errors in run_pure()/eval_subshell(), and restore loop/dot/func depth and skip_kind on eval_pipe() error unwind. Verified locally on Linux (make, make zos-lint, make check: 128/129 pass).
| * Fix z/OS 64-bit linkage/storage, EBCDIC, editor, and checkout issuesSean Kurtz25 hours8-31/+87
|/ | | | | | | | | | | | | | | | | | | | - Guard #pragma linkage with _LP64 (OS on -m64, OS_UPSTACK on -m32), use bit 31 (0x80000000u) for the OS VL bit, and allocate IGGCSI00/BPXWDY2 work areas via __malloc31() per z/OS C/C++ Runtime Library Reference and Open XL C/C++ 2.2 Compiler Reference. - Use isupper()/isdigit() in complete.c hlq_ok() and an EBCDIC/ASCII-safe ctrl_byte() helper in edit_builtin.c bind_keys(). - Tag temp files with sys_tmp_tag() in fc_edit() and edit_external(), add EINTR retry loops in edit_external(), route edit_bind_list() through out1, and clamp CSI/vi repeat counts against signed int overflow. - Destroy posix_spawn_file_actions_t on error in sys_spawn() and clamp put_name() copy length in sys_posix.c. - Replace non-ISO8859-1 dashes in README.md and C-PROGRAMMING-STANDARDS.md and mark notes/review-2026-11-27.md UTF-8 in .gitattributes so git checkout succeeds on z/OS. Verified locally on Linux (make, make zos-lint, make check: 128/129 pass, only pre-existing linux/i-dscomplete differs); z/OS CBT verification next.
* Merge pull request #48 from skurtz97/add-c-programming-standardsSean Kurtz28 hours1-0/+242
|\ | | | | Add C-PROGRAMMING-STANDARDS.md as the reference standard
| * Add C-PROGRAMMING-STANDARDS.md as the reference standardSean Kurtz28 hours1-0/+242
|/ | | | | | | | | The z/OS C and HLASM programming standards for this project: toolchain and warning flags, type and naming rules, clang-format/clang-tidy policy, memory model, EBCDIC/ASCII handling (including zopen character-conversion conventions), control-block access, and POSIX makefile rules. This document is the reference: zash, ztop and whoson all follow it.
* Merge pull request #47 from skurtz97/tests/regression-gapsSean Kurtz30 hours8-0/+17
|\ | | | | tests: cover the review fixes that landed without one
| * tests: cover the review fixes that landed without oneSean Kurtz30 hours8-0/+17
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 2026-11-28 review merge (#46) and the in-process `( cd dir )` merge (#31) left four changes with no test of their own. Three of the eighteen commits cannot have one, see below. - tests/posix/glob-edge.sh: `deep/*` where `deep` holds a file, a subdirectory, a symlink and a dangling symlink. This is the path the glob change takes when the last component has no literal tail left: it adds what readdir() named without an lstat(), so a directory and a broken link must still appear. Replacing `sb_cstr(&g->path)` with the unterminated buffer in that call makes this test fail. - tests/posix/charset.sh: a reversed range `[z-a]` matches nothing, which is what dash and bash do; the ASCII fast path compares bytes where the EBCDIC path looks up a table, so the two must agree on the edge. - tests/posix/printf-ext.sh: a 5000-character `%s`. The bare `%s` fast path writes the argument straight to the output instead of through the format buffer, so length is now the output's business. - tests/zash/heredoc-tmpdir.sh: a TMPDIR longer than PATH_MAX still produces the here-document, through the pipe fallback. - .exp files regenerated with dash (posix) and ./zash (zash), then reviewed: only the added lines differ. The three commits with no test: - 270ac66 `signal()` to `sigaction()` for SIG_DFL: the disposition set is the same, so no test can tell the two apart. - 06e1dd5 the arena size guard: reaching it needs a SIZE_MAX/2 allocation. - de0d26a the TMPDIR length check itself: a truncated temp name has no `XXXXXX` left, so mkstemp() already failed and the pipe fallback already ran. heredoc-tmpdir.sh pins that fallback, not the check. Verified on Linux (7.3.4-300.fc45.x86_64, 2026-11-28): make check 128 passed, 1 skipped, the known linux/i-dscomplete failure; make asan the same with no sanitizer report; the new posix tests pass against dash too.
* Merge pull request #31 from skurtz97/perf/cd-inprocSean Kurtz32 hours7-31/+109
|\ | | | | perf: run a lone ( cd dir ) without forking
| * Merge main into perf/cd-inproc: one in-process `( cd dir )`, not twoSean Kurtz32 hours144-5912/+10745
| |\ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | main gained an in-process `( cd dir )` of its own with the 2026-11-28 review merge (the uncommitted working tree the review was written against, committed as cb1688f), so this branch and main both replaced the fork for the same command, in two places. That copy has a defect this branch guards against: with readonly PWD; ( cd / ); echo after the readonly assignment raises out of the saved-cwd block and kills the whole shell - no `after` - where dash and bash both print it (dash rc=2, bash rc=1). `subshell_in_process()` here refuses to run the `cd` in-process unless PWD and OLDPWD are plain, and `builtin_cd_isolated()` holds its own exception handler, so the fork still happens in that case. Resolution: keep this branch's implementation and drop main's ad-hoc branch in eval_subshell() together with the curdir_invalidate() helper added for it, which had no other caller. The tests main brought with it (tests/zash/subshell-cd.sh, tests/proc/subshell-pure.sh) still pass. Verified on Linux (7.3.4-300.fc45.x86_64, 2026-11-28): make check 127 passed / 1 skipped / the known linux/i-dscomplete failure, make asan and make valgrind the same, make mvs-asan 127 passed, make zos-lint clean, the readonly-PWD case now matches dash. Not re-run on cbt.
* | Merge pull request #46 from skurtz97/fix/review-2026-11-28Sean Kurtz32 hours50-4864/+6928
|\ \ | | | | | | Fixes from the 2026-11-28 code review
| * | docs(design): list base#number with the extensionsSean Kurtz46 hours1-0/+1
| | | | | | | | | | | | | | | | | | parse_based() now reads bases up to 64 with the bash/ksh93 digit set, and refuses a base out of range or a number that overflows, so the extension table and the specification (R-ARI-8) say the same thing.
| * | docs(spec): write down base#number and trimming of each positionalSean Kurtz46 hours4-4789/+4979
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two behaviours the review-2026-11-28 fixes settled and the specification did not state: - R-ARI-8: `base#number`, 2 to 64, digits 0-9 a-z A-Z @ _, errors on a base out of range, no digits, a digit not in the base and overflow. It is an extension, as in bash and ksh93, and the arith-base tests now cover it. - R-EXP-9: `${@#p}` and friends trim each positional parameter before the results are joined by the `$@`/`$*` rule, which is what trim-all tests. Regenerated from formal/zash-spec.typ with typst 0.15.1: the PDF, the HTML export and (pandoc, plain) zash-spec.txt. The Lean model is untouched.
| * | perf(pattern,printf): skip the class table on ASCII, a bare %s through vsnprintfSean Kurtz46 hours2-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in_range() looked the two ends of `[a-z]` up in the alpha/digit tables to get alphabet order. In ASCII the code order *is* the alphabet order, so the compiler can take one comparison; the tables stay for EBCDIC. convert() formatted a bare "%s" through the spec builder and vsnprintf(), which pads, truncates and checks flags it was never given. Out it goes straight to out_puts(); anything with a flag, width or precision still takes the general path. make check unchanged (126 passed, 1 skipped, known linux/i-dscomplete); the whole suite under ASan+UBSan reports nothing.
| * | perf(glob): do not lstat() a component readdir() just namedSean Kurtz46 hours1-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The last component of a pattern was matched by readdir() and then stat'ed again by the recursive call, only to learn that the name it had just read exists. When nothing follows the component, add it straight away; a literal tail and a trailing `/` still go through lstat(), the second because `*/` must not match a file. Measured on Linux (x86-64) with 3000 names in one directory and `set -- d/*` run 200 times: 0.20 s before, 0.05 s after, three runs each, same result count. make check unchanged (126 passed, 1 skipped, the known linux/i-dscomplete failure on this machine).
| * | fix(signal): install SIG_DFL with sigaction, not signal()Sean Kurtz46 hours4-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | Two places reset a signal to its default: main() for an inherited SIGCHLD (waitpid() fails with ECHILD when a parent left it ignored) and the pipeline child that writes a long builtin output and must die on SIGPIPE. Both went through signal(), which differs from sigaction() in restart and mask behaviour; they now share trap.c's set_handler() through a small trap_sig_default(), the function trap_reset() already uses.
| * | fix(redir): reject a TMPDIR too long for the here-document pathSean Kurtz46 hours1-1/+4
| | | | | | | | | | | | | | | | | | | | | The snprintf() into path[PATH_MAX] was unchecked: with a TMPDIR longer than that, the name was truncated and mkstemp() could be pointed at a different directory than the one meant. The length is now checked and the here document falls back to the pipe it already uses on failure.
| * | fix(util): refuse an arena size that would overflowSean Kurtz46 hours1-0/+4
| | | | | | | | | | | | | | | | | | | | | arena_alloc() aligned the size and arena_add_chunk() added sizeof (arena_chunk) to it before malloc(), so a size near SIZE_MAX wrapped and handed back a short block. Both now go through out_of_memory() above SIZE_MAX / 2, the same way xmalloc() treats a failed malloc.
| * | fix(edit): vi search reads its pattern into a buffer of its ownSean Kurtz46 hours3-4/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `/` wrote the new pattern over the old one in ed.search and only wrote a terminator when something had been typed. Type `ban` over `apple`, delete the three letters, press Enter: the buffer still held "banle", so the "empty pattern repeats the previous search" case searched a mix of the two and found nothing (the terminal just beeped). vi_read_pattern() collects the pattern in a local array and copies it into ed.search only when it is non-empty; an empty pattern now really does leave the previous one alone. Test: tests/linux/i-vi.sh searches for apple, then types `ban` + three backspaces + Enter, and expects `echo apple` back. Without the change the line stays empty. Verified on Linux with make check.
| * | fix(edit): quote the temporary file name for the editorSean Kurtz46 hours4-10/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `v` and `fc -e` handed the editor "%s %s" of the editor and the mkstemp file name, unquoted: with a TMPDIR holding a space or a `$` the editor saw a path cut at the space, wrote nothing, and `fc` ran the original commands again. The name now goes through out_quote() into an OUT_MEM buffer, so the shell reads it back as one word; `sprintf` is gone. Both commands also left the file behind when the editor command raised an exception (a syntax error in $EDITOR, for one), because the raise jumps past unlink(). They now catch it, unlink, and re-raise, the same way the builtin wrapper in exec.c does. fc_edit() also ignored a write error on the temporary file and went on to run the editor; it now reports it and removes the file. Test: tests/linux/i-fc-tmpdir.sh runs fc and `v` with TMPDIR="tmp dir$x" through ptydrive, including a raising editor command, and then checks the directory is empty. Without the change the editor is handed the broken path and no file appears. Verified on Linux with make check and the test under ASan+UBSan.
| * | fix(expand): trim each positional parameter for ${@#pat}Sean Kurtz46 hours3-7/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `"${@#ab}"` with `set -- abc abd` joined the parameters first ("abc abd"), trimmed the join, and emitted that as a single field ("c abd"). ksh93 and bash trim each parameter and then apply the "$@" rules: two fields, "c" and "d". expand_all_params() takes the pattern and the operator and trims every parameter before emitting, so `"${@#pat}"` still gives one field each, `"${*#pat}"` one field joined by IFS, and unquoted both split as before. join_params_trimmed() is the join path, and trim() gets a forward declaration because it sits further down the file. Test: tests/zash/trim-all.sh, twelve lines covering all four operators, @ and *, quoted and unquoted, empty parameters and a non-blank IFS. The expected output is ksh93's and bash's, which agree line for line. Verified on Linux with make check.
| * | fix(ulimit): refuse a limit that does not fit rlim_tSean Kurtz46 hours3-8/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `ulimit -s 18014398509481984` (2^54 kbytes = 2^64 bytes) multiplied a 64-bit value by 1024 and wrapped to 0: the command succeeded and set the stack limit to zero. It is now "limit out of range" and status 1, and so is a value that would come out exactly RLIM_INFINITY without the user writing "unlimited". The `ulimit -a` label was copied into a 64-byte buffer for no reason; "% -20s" gets the name straight from the table. And if a build has no RLIMIT_FSIZE entry there is no default resource at all, so say that instead of dereferencing a null pointer. Test: tests/zash/ulimit.sh, in a subshell so a broken build cannot take the test shell down with it. Verified on Linux: before the change the command exits 0 and `ulimit -s` reports 0; after it, the warning and status 1.
| * | fix(edit): vi `y` keeps the line and never pastes the old killSean Kurtz46 hours3-15/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `y0` with the cursor at column 0 yanks an empty range, and the old code then inserted the kill buffer at the cursor: with nothing killed yet that was memcpy(dst, nullptr, 0), which UBSan rejects at src/edit_builtin.c:375; with an earlier `cw` behind it, the old kill text was pasted into the line (vi `y` changes nothing on the line). The `y` case now copies the range into the kill buffer with kill_set() - the same block remove_range() used - and puts the cursor at the start of the range, which is where vi leaves it. insert() also returns early for an empty string, so a later caller cannot repeat the null memcpy. Test: tests/linux/i-vi.sh yanks an empty range after a `cw`, so the kill buffer holds text that must not appear. Before the change UBSan reports "null pointer passed as argument 2" and the line comes out as "oneecho yank"; after it, the line is "echo yank". Verified on Linux with make check and the same pty session under ASan+UBSan.
| * | fix(printf): a negative '*' precision is no precisionSean Kurtz46 hours3-4/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `printf '%.*d' -5 1` built the conversion "%.-5jd" and printed it literally: a width and precision taken with '*' were written with "%d" of an (int) cast, so a negative precision produced ".-5" in the spec. copy_number() now writes the value with "%jd" - no narrowing, which the review asked for - and, for a precision, drops the '.' again when the value is negative: C99 says a negative precision is as if it were omitted. A negative width stays, where snprintf() reads the '-' as a flag. tests/posix/printf-ext.sh covers all four shapes; the expected output is what dash and bash print. Verified: make check, and the same test under ASan+UBSan on Linux.
| * | fix(arith): parse base#digits without signed overflowSean Kurtz46 hours3-7/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `$((99999999999999999999#1))` multiplied its way through INT_MAX: UBSan reports "signed integer overflow" at the base loop in parse_based(), and in a release build the resulting base is whatever the wrap gave. The base is now built with a bound (anything over 64 is "bad number base" at once) and the digits are read by hand against ksh's digit set, so `16#0x10`, `16# f`, `2#2` and `16#` stay errors instead of relying on strtoumax()'s quirks. The digit set is a string looked up with strchr(), not arithmetic on character codes: the letters are not contiguous in EBCDIC, and the same source has to work on both sides. That also makes bases 37 to 64 work, as they do in ksh: `$((64#z))` is 35, `64#_` is 63, `64#@` is 62. Values still wrap at UINTMAX_MAX, which is what the old code did for everything else, so a literal that does not fit is still "bad number". Verified: before the change, zash-asan reports src/arith.c:270 signed integer overflow for the huge base and rejects 64#z; after it, the new tests pass under ASan+UBSan on Linux. The EBCDIC build is untested here (the mapping is a string constant, so it does not depend on the charset).
| * | fix(exec): run the ERR trap when the last command is exec'dSean Kurtz46 hours5-2/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `trap "echo ERR" ERR; /bin/false` printed nothing: the shell replaced itself with the failing program and was gone before the trap could run. The same shortcut made `trap ... ; (/bin/false)` silently skip it. trap_after_last() is true when the EXIT or the ERR trap is set, and both the exec shortcut in run_external() and the in-process subshell shortcut in eval_subshell() now use it instead of trap_has_exit(). tests/zash/errtrap-exec.sh covers the external command, a builtin, a subshell and the two traps together; the first and third lines fail without the change. ksh93 prints ERR for all four.
| * | fix(parser): save and restore the parser state in run_inputSean Kurtz47 hours6-4/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A trap that fires while a command is half parsed, and vi's `v` command, both run eval_string() from inside the outer parse. The nested parse_command() points the static arena at its own arena, and freeing that arena leaves the outer parse allocating from freed memory: silent corruption in a release build, heap-use-after-free under ASan. run_input() now brackets its whole body with parser_save()/parser_restore() on every way out - the normal return, the error unwind and the EXIT unwind of the recover loop - so any nested eval, present or future, is safe. in_cond and alias_ended_blank join parser_state because a nested parse changes them too; the static_assert keeps the snapshot buffer in step. Also move here_tail's doc comment back above here_tail. Tests: - tests/posix/trap-midtoken.sh: a trap delivered mid-token from a pipe. It reports heap-use-after-free under `make asan` before the change and passes after it. - tests/linux/i-vi-edit.sh: `v` with $VISUAL, $EDITOR and a failing editor through ptydrive; the edited line runs. Verified on Linux (clang 20, -O3 -g) with `make check` and ASan+UBSan.
| * | tests: regenerate i-vi.exp for the change and dot-repeat stepsSean Kurtz47 hours1-1/+11
| | | | | | | | | | | | | | | | | | | | | The script gained the change/dot-repeat steps but the expected output still stopped at 'echo done'. The ten lines it prints now are right: 0wx.. deletes three letters, 0dw. deletes two words, and after a motion (l) the dot repeats the last change (x), not the motion.
| * | wip: vi external edit and dot-repeat, in-process cd subshell, perf testSean Kurtz47 hours18-20/+1436
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | The working tree the 2026-11-28 review was written against, committed unchanged so the review fixes can sit on top of it. - vi mode: `v` edits the line in $VISUAL, else $EDITOR (edit_external), and `.` repeats the last change, count and all. - `( cd dir )` runs in-process with the directory saved and restored, instead of forking, and its invalidation of the cached logical cwd. - tests/perf: a start-up cost guard; tests/run.sh runs that directory. - README: set +o pipetag for ASCII builds. - formal/zash-spec.txt regenerated as text. - .clang-tidy: two checks re-enabled (no findings after the change). - tests/scripts/webdocs: a `#` inside a fenced block is not a title.
* | Merge pull request #45 from skurtz97/feat/select-and-docsSean Kurtz2 days18-4938/+5410
|\ \ | | | | | | select, the ksh88 menu loop; webdocs fixed; successor framing in the docs
| * | docs: zash is the successor to IBM's ksh88 /bin/shSean Kurtz2 days3-17/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | The shell it replaces is not a different language: it is of the KornShell line, and a script written for it runs under zash. Say that where the documents used to imply the opposite -- "the dash of z/OS", "the z/OS /bin/sh's semantics are not emulated" -- and sort what is left into places where IBM departs from POSIX (zash follows POSIX) and the few ksh88 features zash declines.
| * | feat: select, the ksh88 menu loopSean Kurtz2 days11-4889/+5234
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IBM's /bin/sh is of the KornShell line and `select` is part of what its scripts use, so the shell that replaces it has to have it. The menu goes to stderr as "number TAB word", then PS3 (default "#? "); the answer is read with the rules of `read REPLY`; a number in range picks that word, anything else leaves the variable empty and the body still runs, a blank line only prompts again, and end of input ends the loop. The node is the `for` node with a `menu` flag, since the two differ only in what the body sees. tests/zash/select.sh prints the same bytes under zash and under the CBT /bin/sh; the specification has the rule.
| * | fix(webdocs): make a script out of the page maker, and test itSean Kurtz2 days4-32/+132
|/ / | | | | | | | | | | | | | | | | | | make reads a `$` in a recipe as a variable reference, so the awk program that stripped the logo, the author line and the contents list arrived without its `$`, the README page came out empty and `make webdocs` said nothing. The page maker is now web/site-page.sh, which also names the page after the document rather than after the path the Makefile happened to pass, and tests/scripts/webdocs.sh checks the result: front matter, no logo or contents list, links rewritten.
* | Merge pull request #44 from skurtz97/fix/zos-tagging-and-csiSean Kurtz2 days10-4957/+5216
|\ \ | | | | | | z/OS tagging: the decoder in both character sets, and the tagging rules as built
| * | docs: the tagging rule as the code does it, and input errors in the specfix/zos-tagging-and-csiSean Kurtz2 days4-4948/+5030
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DESIGN.md's "File tags" table said an ASCII build defers the tag on a `>` target and takes the first writer's CCSID; sys_zos.c tags a file the shell creates as IBM-1047 text and converts its own writes, and the paragraph "the tag follows the writer" now says that deferred tags are the _TAG_REDIR_* cases only. The shell's own stdout and stderr are in the table now, and the reason the inherited conversion is harmless to a binary writer (gzip turns it off, and tests/zos/tagging.sh checks the archive) is written down. The specification records what a script reviewer needs: R-LEX-17 no longer just ends the body at end of input, it says zash does not warn where bash does, and the new zash-only error rule gives 127/126 for a script that cannot be opened and 2 for a read error while input is being read. The PDF is regenerated.
| * | tests: pin the CSI type byte in both character sets, and a gzip archiveSean Kurtz2 days6-9/+186
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CSI entry type byte is converted from EBCDIC in an ASCII build and must be used as it is in an EBCDIC build (notes/review-2026-11-27.md, item 12). Nothing but Tab completion on z/OS reaches that code, so the test drives the decoder directly: tests/tools/csi.c builds a work area with one data set, one user catalog connector and one catalog entry, and asks csi_parse() for the names. On z/OS the Makefile builds it twice, once per character set, and tests/zos/csi-parse.sh runs both; each prints a verdict, so one expectation covers both builds. tests/zos/tagging.sh gains the case the review asked for: a gzip archive made through zash (with its stdout tagged and converting) must be byte for byte the archive /bin/sh's redirect makes. It is: gzip turns conversion off for its own output, and the 1047 tag is the one /bin/sh leaves on this host too (_BPXK_AUTOCVT=ON, _CEE_RUNOPTS=FILETAG(AUTOCVT,AUTOTAG)).
* | Merge pull request #43 from skurtz97/fix/review-2026-11-27Sean Kurtz2 days70-190/+1365
|\ \ | | | | | | fix: the review findings, each with a regression test
| * | tests: expect what z/OS does, and keep the review notesfix/review-2026-11-27Sean Kurtz2 days4-1/+472
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The host was verified with IBM make and IBM Open XL, in a copy of the tree (`tar`, extract, `chtag -R -t -c ISO8859-1 .`, `/bin/make zos-check`): plain `make` still dispatches to zos-ascii, both binaries build without a warning, the ASCII suite is 112 passed / 6 skipped / 0 failed, and the EBCDIC subset passes. Two expectations cannot be the same on both hosts, so zash/script-errors keeps the POSIX cases and is skipped on z/OS (a mode 000 script still runs there, because bit mode does not decide access), and tests/zos/ script-errors records the z/OS side. notes/review-2026-11-27.md now has a per-item status table, the investigation results and the z/OS run.
| * | fix: the review findings, each with a regression testSean Kurtz2 days66-189/+893
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Notes in notes/review-2026-11-27.md, one item per finding: 1. error unwinding read dead stack frames: the scope/redirection/input snapshot now lives in jmploc and is restored before the longjmp 2. `for` without `in` iterated over parameters that `set --` could free: the parameter block is reference-counted 3. `${4294967295}` and `${99999999999999999999}` indexed past the end: strtol, clamped to 1..$# 4. a trap stopped running after its own action raised: the re-entry flag is cleared before the action runs 5. `wait $pid` returned 127 once the job had been reaped 6. every external command failed with 127 when SIGCHLD was ignored at startup: dispositions are reset before the first child 7. a failed `exec` killed an interactive shell and skipped its EXIT trap: the shell returns 126/127, keeping the traps and restoring fds 0-9 8. `set -C` opened with O_TRUNC after a stat: O_EXCL, with the non-regular-file case worked around 9. a here-doc cut off by EOF used the delimiter as its body 10. `cd -- dir` failed and PWD came from the failed logical path 11. deep arithmetic recursion overflowed the stack: a depth check 12. the CSI type byte was converted twice on EBCDIC: guarded by ZASH_ASCII 13. a script that could not be read looked like an empty script: reported, with 2 at top level and 126/127 for the script; a directory is refused up front, because z/OS would otherwise read it as empty input Minors: `trap -p SIG`, `read -t` clamping and NaN, ksh `base#n` arithmetic, `${#@}`/`${#*}` as `$#`, `jobs` no longer mutating its table from a pipeline, the arena_grow contract, no pipe2 on macOS, and alias text copied into the input so redefining an alias while it is being read is safe.