| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
| |
- 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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`"${@#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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`$((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).
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |/
|
|
|
|
|
| |
A subshell whose body is a single cd now runs in the parent shell with
the directory, PWD, OLDPWD and curdir saved and restored, instead of
forking. On z/OS a fork costs ~0.4 ms there; the cd itself costs ~5 us.
A readonly, integer or dynamic PWD/OLDPWD keeps the forked path.
|
| |
|
|
|
|
|
|
| |
tag shows and sets file tags in chtag -p form without a process; alloc
and free pass BPXWDYN requests. They exist only in z/OS builds (free
must not hide procps elsewhere) and in make mvs-asan's build, which runs
their usage-error test; tests/zos/builtins.sh covers the real work
(unrun, VERIFY).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Tagging and conversion (sys_zos.c, redir.c, input.c, var.c, exec.c):
- _TAG_REDIR_IN/OUT/ERR as /bin/sh documents them, cached by variable
hooks so redirection tests a byte; honoured as a prefix on external
commands and on pipeline stages.
- ASCII builds tag new output and here-document files as text, tag
pipes IBM-1047 (set +o pipetag to stop), and switch on autoconvert.
- Scripts, . files, profile and ENV are read in either character set:
tagged files get F_CONTROL_CVT, untagged ones are sniffed.
- tag/chtag primitives (sys_tag_get/sys_tag_set) for a builtin to come.
Data set completion (complete.c, mvsfmt.[ch], zos_csi.s):
- //'HLQ.PART, "//'HLQ.PART, //NAME (user HLQ), //'DSN(MEM, //DD:NAME
complete one qualifier at a time from the Catalog Search Interface,
PDS directories and the TIOT.
- IGGCSI00 is called through HLASM glue that switches to AMODE 31 and
keeps every register and parameter below the bar (VERIFY).
- The work-area, directory and TIOT decoders are portable and run on
Linux against a stand-in catalog that produces the real EBCDIC bytes,
including CSI resume and directory-block splits; fuzzed with
libFuzzer (make fuzz).
- A lone completion inside quotes now closes the quote.
Other z/OS features:
- time [-p] keyword with shell/children CPU split.
- set -o jobnames (_BPX_JOBNAME per command), set -o shareas
(_BPX_SHAREAS=YES for foreground commands only), set -o msgid
(ZSHnnnnE/W message IDs), ulimit -M (MEMLIMIT), ZOS_SYSNAME,
ZOS_SYSPLEX, ZOS_RELEASE, ZOS_ASID, ZOS_JOBNAME, prompt \S.
- BPXWDYN entry point for an alloc builtin to come.
Checking z/OS code off z/OS:
- make zos-lint compiles sys_zos.c against declarations transcribed
from the z/OS headers, and the rest with the MVS paths forced on.
- make mvs-asan runs the suite with the MVS paths on, under ASan/UBSan.
- make asan and make valgrind now check for leaks.
|
| |
|