<feed xmlns='http://www.w3.org/2005/Atom'>
<title>zash.git/tests/zash, branch main</title>
<subtitle>Fast Almquist-family POSIX shell for z/OS UNIX with bundled libedit</subtitle>
<id>https://git.abendless.com/zash.git/atom?h=main</id>
<link rel='self' href='https://git.abendless.com/zash.git/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/'/>
<updated>2026-11-29T04:02:44Z</updated>
<entry>
<title>Add regression tests for audit fixes and clear clang-tidy findings</title>
<updated>2026-11-29T04:02:44Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-29T04:02:44Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=3ded9a80de9a487bcae31c695740d82d1a0e13fd'/>
<id>urn:sha1:3ded9a80de9a487bcae31c695740d82d1a0e13fd</id>
<content type='text'>
- 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.
</content>
</entry>
<entry>
<title>tests: cover the review fixes that landed without one</title>
<updated>2026-11-28T22:34:52Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-28T22:34:52Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=648125a5ef1a98519c5d2cd66c4f015bcb8b5b1f'/>
<id>urn:sha1:648125a5ef1a98519c5d2cd66c4f015bcb8b5b1f</id>
<content type='text'>
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(&amp;g-&gt;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.
</content>
</entry>
<entry>
<title>Merge main into perf/cd-inproc: one in-process `( cd dir )`, not two</title>
<updated>2026-11-28T20:34:40Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-28T20:34:40Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=78d73092a29cca7e3ce4ef6b5e2c6cd244f40202'/>
<id>urn:sha1:78d73092a29cca7e3ce4ef6b5e2c6cd244f40202</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>fix(expand): trim each positional parameter for ${@#pat}</title>
<updated>2026-11-28T06:33:12Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-28T06:33:12Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=662f3b37dcfad0fd2f193762464c1b9701c96db9'/>
<id>urn:sha1:662f3b37dcfad0fd2f193762464c1b9701c96db9</id>
<content type='text'>
`"${@#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.
</content>
</entry>
<entry>
<title>fix(ulimit): refuse a limit that does not fit rlim_t</title>
<updated>2026-11-28T06:31:36Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-28T06:31:36Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=447151dabfbad0a41c8f049938042cd886d9f451'/>
<id>urn:sha1:447151dabfbad0a41c8f049938042cd886d9f451</id>
<content type='text'>
`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.
</content>
</entry>
<entry>
<title>fix(arith): parse base#digits without signed overflow</title>
<updated>2026-11-28T06:23:42Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-28T06:23:42Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=ec1cd3eb8e1aa177329f25d134f372d3e999d4a4'/>
<id>urn:sha1:ec1cd3eb8e1aa177329f25d134f372d3e999d4a4</id>
<content type='text'>
`$((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).
</content>
</entry>
<entry>
<title>fix(exec): run the ERR trap when the last command is exec'd</title>
<updated>2026-11-28T06:18:38Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-28T06:18:38Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=9cdf5f548dc8e1d5c6315b304819bf0fd60f802f'/>
<id>urn:sha1:9cdf5f548dc8e1d5c6315b304819bf0fd60f802f</id>
<content type='text'>
`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.
</content>
</entry>
<entry>
<title>wip: vi external edit and dot-repeat, in-process cd subshell, perf test</title>
<updated>2026-11-28T06:08:16Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-28T06:07:39Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=cb1688f0233d53cfca8078f812c824213a5617fd'/>
<id>urn:sha1:cb1688f0233d53cfca8078f812c824213a5617fd</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>feat: select, the ksh88 menu loop</title>
<updated>2026-11-28T03:48:49Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-28T03:48:49Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=ced8928b067a3bd3047f7e094eb9d9d575ae9444'/>
<id>urn:sha1:ced8928b067a3bd3047f7e094eb9d9d575ae9444</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>fix: the review findings, each with a regression test</title>
<updated>2026-11-27T23:26:45Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-27T23:26:45Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=90e25207c41010a5307beff7fd7a5a9e4be3653e'/>
<id>urn:sha1:90e25207c41010a5307beff7fd7a5a9e4be3653e</id>
<content type='text'>
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.
</content>
</entry>
</feed>
