summaryrefslogtreecommitdiffhomepage
path: root/tests/posix
Commit message (Collapse)AuthorAgeFilesLines
* tests: cover the review fixes that landed without oneSean Kurtz33 hours6-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* fix(printf): a negative '*' precision is no precisionSean Kurtz2 days2-0/+3
| | | | | | | | | | | | | | | | | `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(parser): save and restore the parser state in run_inputSean Kurtz2 days2-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* fix: the review findings, each with a regression testSean Kurtz2 days22-2/+175
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* test: check the PATH suffix without a line-length-limited grepSean Kurtz6 days1-1/+1
|
* fix: make zopen checks run in the foreground and tolerate a long CFLAGSSean Kurtz6 days1-0/+2
|
* chore: clangd sysroot note, shellcheck header, typst formattingchore/editor-and-lint-hintsSean Kurtz6 days1-0/+3
|
* z/OS: run 31-bit and load IGGCSI00 through the C librarySean Kurtz7 days2-3/+3
| | | | | | | | | | | | | zash was AMODE 64, so calling the AMODE 31 IGGCSI00 needed assembler glue (zos_csi.s) that switched addressing mode around the branch. Built with -m32 the program is 31-bit itself: the call goes through a plain function pointer, the work area and the saved registers live in one 31-bit block in C, and the glue is gone. The rest of the tree follows the change: the build, the off-z/OS lint shim, DESIGN.md and README.md, the benches, the Lean spec of the pattern matcher, and the tests that recorded what the extra address bits had changed.
* tests/posix/test-ops: do not expect -s to be true for a directorySean Kurtz12 days2-1/+3
| | | | | z/OS reports a directory size of 0 and POSIX lets a system choose it, so one line of the loop depended on the platform's stat().
* z/OS ASCII build: IBM-1047 on pipes, here-docs, redirects, std streams; ↵Sean Kurtz12 days2-2/+2
| | | | fdmap test independent of /bin/sh
* Errors in command-prefixed special builtins no longer exit; no arena leakSean Kurtz2026-11-152-0/+47
| | | | | | | | | | | | | | `command eval`, `command .` and friends lose the special property that an error exits a non-interactive shell (POSIX 2.14, and dash, bash and ksh93 agree): the error now becomes the status. Only that path pays for a setjmp(). run_input() released its parse arena only on the normal path; an error caught further out (a subshell, command, the prompt) leaked it. Found by running the suite under Valgrind with leak checking, which is now on for make valgrind and make asan. Also renames two locals that shadowed the cond typedef (gcc -Wshadow).
* Edge-case, integration and z/OS tests, including z/OS stand-insSean Kurtz2026-11-1526-0/+739
| | | | | New groups: tests/scripts (integration, expectations from dash) and z/OS data set, tso, EBCDIC and tagging tests with Linux stand-ins.
* Tests and benchmarks for the extensions and the interactive layerSean Kurtz2026-11-133-3/+0
| | | | | | | | New zash/ tests for each extension, a proc/ test showing they create no processes, and linux/i-*.sh tests that drive the interactive shell on a pseudo-terminal (tests/tools/ptydrive.py; skipped without python3). The runner counts exit status 77 as "skipped". Adds a benchmark for the arithmetic commands and removes a stray file from tests/posix.
* zash: scripting core, test suite and benchmarksSean Kurtz2026-11-1249-0/+1789
A clean-slate POSIX shell for z/OS UNIX in the Almquist tradition, written in C23 for Clang (Linux) and IBM Open XL C/C++ (z/OS). - Parser, expansion, arithmetic, redirection, traps and builtins. - Spawn-first execution: fd plans instead of fork+dup2, in-shell pure builtins for pipelines and command substitution, $(a | b) without a subshell. - Flat .POSIX Makefile; asan, valgrind, bench, compdb and z/OS targets. - Tests: posix (dash-generated), zash, process accounting, linux, zos. Nothing has been compiled or run on z/OS yet.