| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
- 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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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.
|
| |\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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).
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`/` 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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`"${@#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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`$((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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
libedit was a compile-time alternative (`make EDIT=libedit`). It goes:
FreeBSD and NetBSD `sh` use it because it is in their base system, which
is not the case on z/OS, and it cost about a third of a millisecond to
reach the prompt -- three more shared libraries, `el_init()`, an
`~/.editrc` read and a copy of the history -- for the same cost per key.
What it bought was `~/.editrc` bindings and a kill ring; `bind` and the
built-in editor's own bindings cover the keys, and a second editor meant
a second build mode and a second set of interactive expectations, with
seven tests skipping under it.
Everything that existed only to serve two editors goes with it: the
`EDIT` switch and the two `edit_$(EDIT)` paths in the makefile, the
`$ZASH_EDITOR` variable the tests used to skip, the skip guards in
`tests/linux/`, the NUL stripping in `ptydrive.py` that libedit's redraw
needed, and the parallel paragraphs in README.md, DESIGN.md,
bench/README.md and the two website pages. `bench/README.md` keeps the
measurement, since that is why the decision is written in DESIGN.md.
Checked on Linux (97 passed, 1 skipped, the one known local failure in
linux/i-dscomplete) and on z/OS (64 passed, 3 skipped, 0 failed, plus the
EBCDIC build).
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The libedit editor had no Tab binding at all, so the same line typed in
the two builds behaved differently: `myalias<Tab>` completed under the
built-in editor and ran the name as written under libedit. Completion is
not an editor feature here — it is the shell's, from complete.c — so the
boundary moves: complete.c now owns the escaping (`complete_escaped()`)
and the candidate listing (`complete_listing()`), and each editor only
inserts the result into its line.
For libedit that means a function bound to ^I: it deletes the word,
inserts the escaped candidate, finishes a unique one with a space and
asks for a full redraw (a tail-only refresh left the terminal showing a
line the shell did not have). Two things cost time to find: the binding
name is the editrc spelling `^I`, not a literal Tab, and EL_EDITOR has to
be set before EL_ADDFN/EL_BIND, because selecting an editor replaces the
key map and drops what was bound before.
$ZASH_EDITOR says which editor is compiled in. Keys, redraw and listings
are the editor's own — libedit reads ~/.editrc, and its redraw of a
prompt that starts with an OSC title leaves one space too many on the
screen — so the interactive tests that encode the built-in editor's
bindings and drawing skip under libedit, with a reason. i-complete, which
covers the completion both now share, passes under both.
tests/tools/ptydrive.py drops NUL bytes from what it compares: libedit
writes a run of them after "erase to end of line" when it redraws, and a
NUL puts nothing on a screen.
Built-in build: 97 passed, 1 skipped, 1 failed (linux/i-dscomplete, the
known local failure). libedit build: 6 passed, 7 skipped, 0 failed.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The built-in editor skipped `ESC [ ...` sequences when working out where
the prompt ends. Colour and titles are not all CSI: an OSC title or
hyperlink runs to BEL or `ESC \`, DCS runs the same way, and `tput sgr0`
is the three-byte `ESC ( B` before `ESC [ m`. A prompt built with
`$(tput ...)` was measured wrong, which costs the cursor position and
with it the wrapped-line arithmetic.
`esc_seq_len()` in interact.c now walks what a terminal understands, and
edit_builtin.c uses it. The libedit build shares the walk: it brackets
control runs for `EL_PROMPT_ESC`, and adds the space libedit needs when
a prompt ends in one, since libedit attaches a literal run to the
character after it.
bench/editor.py measures the two costs run.sh cannot see, start to first
prompt and per-key echo, on a pty; bench/README.md has the table. The
release, z/OS and fuzz builds move to -O3 while the sanitizer and
coverage builds stay low: inlined frames make their reports harder to
read than the few percent they would gain.
|
| | |
| |
| |
| |
| |
| |
| | |
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.
|
| |/ |
|
| |
|
|
|
|
|
|
| |
A constexpr at file scope has external linkage, so the CSI offsets and
CSI_MAX_CALLS now say static. The naming check gets the C23 spellings
wrap the check itself: typed constants keep the macro case, and a local
static constexpr table keeps the variable case. .clangd says -std=c23,
which it still did not, so the editor could not read constexpr at all.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
input_push_fd() called sys_input_cvt() for every script on z/OS, and that
routine converts to the program's own CCSID. In an ASCII build reading
an IBM-1047 system it therefore either asked for EBCDIC-to-EBCDIC
conversion, which is a no-op that returns 0, or read the bytes
unconverted; SETCVTON on a descriptor that sys_dupfd() has renumbered
returns 0 and converts nothing on this system either. The parser then
saw EBCDIC and dropped the script.
An EBCDIC build reads IBM-1047 natively and never wanted the call. With
the conversion left to ASCII builds, posix/traps and scripts/signals pass
on z/OS: 93 passed, 4 skipped, 0 failed.
The untagged-file case still depends on SETCVTON with an explicit fccsid,
which is unverified, so the VERIFY note stays.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
nullptr in every place a null pointer constant was meant; NULL is gone
from src/.
constexpr where it improves on #define without costing anything: the
IGGCSI00 work-area offsets and sizes, and the scalar sizes MVS_DSN_MAX,
CSI_FIELD_LEN, CSI_WORK_MIN, PDS_DIRBLK, CSI_WORK, CSI_MAX_CALLS. A
constexpr in C is a constant expression, so it still bounds the arrays
that use it, and it now carries a type and can be checked with
static_assert. Feature switches (#if), the CSIETYPE/EBCDIC byte
constants read as octets, and the related-constant enum sets stay as
they were.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The z/OS toolchain would not take C23 when this was first written; IBM
Open XL C/C++ 2.2 does (clang 21.1, __STDC_VERSION__ 202311), and so
does the clang on Linux. -std=c23 in the Makefile, and the standard
attributes in place of the ones that were macros:
_Noreturn -> [[noreturn]] (on declarations and definitions)
_Static_assert -> static_assert
_Alignas -> alignas
NODISCARD -> [[nodiscard]]
FALLTHROUGH -> [[fallthrough]]
PRINTFLIKE and UNREACHABLE() stay macros: [[gnu::format]] and
[[gnu::unreachable]] are vendor attributes, and the standard has no
[[format]] or [[unreachable]] for a header-only project yet.
Standard-library additions newer than the libc of either system
(<stdbit.h>, <stdckdint.h>) are not used, so gcc -std=c2x still builds
the tree warning-free. The suite, ASan/UBSan and the z/OS lint pass as
before; linux/i-dscomplete remains the one local failure it was on
main.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The 31-bit choice existed for one reason: a 64-bit start cost 29 ms
against 1 ms and a 64-bit fork() 4.2 ms against 0.10. That was the
64-bit C run-time being loaded out of CEE.SCEERUN2 on the linklist on
every start; with CELQ* in the dynamic LPA both widths cost 1.5 ms and
fork() 0.10 ms (notes/investigation.md has the before and after).
So build the shell at the width IBM builds for: -m64 for both the
ASCII and the EBCDIC build, and for the debug build.
OS_UPSTACK does not exist at -m64, so the two AMODE 31 services
(IGGCSI00, BPXWDY2) are declared with plain OS linkage, which is what
the 64-bit glue implements. IGGCSI00's VL bit is set from the width of
a pointer now, not with 0x80000000. Neither module loads on this
system, so the linkage itself stays unverified; csi_call() still traps a
program check and retires the catalog if it abends.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
sys_pipe() duplicates the shell's pipe ends above SYS_NFD and marks them
FD_CLOEXEC, so that other children do not inherit them. spawn()'s fd_map
hands the child the parent's descriptor as it is, without clearing the
flag the way dup2() would, so a mapping onto the child's 0..2 carried
FD_CLOEXEC into the child. The child could still write, but the next
exec inside it lost stdout: ps printed
FSUM6004 write error on standard output: EDC5113I Bad file descriptor
and a #!/bin/sh shim lost the pipe it was given.
Pass a plain duplicate, which fcntl F_DUPFD makes above SYS_NFD without
the flag, for every map entry that names a different descriptor, and
close the duplicates once spawn() has made the child. Entries that map
a descriptor onto itself are untouched.
tests/zos/fdmap.sh records the case: a pipe the shell made, read by a
child that execs.
Reported in #1.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| | |
|
| |
|
|
|
|
| |
"Below the bar" means below 16 MB, the 24-bit range. IGGCSI00 needs
31-bit addresses, so the block has to stay below 2 GB -- two very
different limits. Corrected where the two had been confused.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The search interface was reached through LINK, which asked the system to
find and attach the module on every call -- and completion issues a call
per Tab. The glue now LOADs the module on the first call, writes its
entry point into the block, and branches to it directly afterwards, and
the block itself is taken from 31-bit storage on the first search and
kept, because IGGCSI00 is AMODE 31 and all three of its addresses have
to stay below 2 GB.
The block is declared packed, so the compiler cannot add padding the
assembler's offsets do not know about, and aligned(8), so the save area
starts on a doubleword. Its name field is spelled in IBM-1047 bytes
rather than as a C string, so the module is named the same way whatever
character mode this build runs in.
Verified on the machine: SYS1.MA* returns SYS1.MACLIB, SYS1.* returns
135 names, and Tab in an interactive shell completes //'SYS1.MA to
//'SYS1.MACLIB' and lists the members of that PDS.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
A `fork()` copies the address space on z/OS, where a `spawn()` can share
it. The subshell row measured 4.7 ms a turn there against 0.3 ms for an
external command, and ksh88 does not fork for `( : )` at all.
The pipeline stage check already answered the safety question with
is_pure(), so a subshell whose body is one output-only builtin with no
redirections and no assignments reuses the answer and runs in the shell.
Expansion of the arguments is wrapped in the same capture scope a
pipeline stage uses, so ${x=1} no longer escapes.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
DESIGN.md, README.md and the Doxygen comments leaned on semicolons to
join clauses and on trailing "which" clauses to add afterthoughts. Both
read as machine-written prose. Each joined clause is now its own
sentence, and the afterthoughts are either part of the sentence or a
sentence of their own.
Also corrected: README said C11 in two places (the tree builds C17), the
completion section still described the pre-HLQ-rule filters and the
64-call resume limit, and the z/OS job-control note still called
SPAWN_SETTCPGRP unverified.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A filter whose first qualifier is generic makes Catalog Management
resolve aliases generically, and the manual warns that a generic
high-level qualifier can select several catalogs at once: a high-level
of "**" means every user catalog. Tab is no reason to ask that of the
catalog address space, so completion waits until a whole high-level
qualifier is typed before it searches at all.
The searches are narrower too: entry types U (user catalog connector)
and X (alias) are excluded, since they are not data set names; the
required return-area length is checked before a resume, as Managing
Catalogs asks; and the editor lists at most one screenful of
candidates, with a count of the rest, instead of a fixed 200.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
CSIS1CAT keeps a generic high-level qualifier from fanning a Tab key out
over every alias it matches plus the master catalog, which is what
Managing Catalogs warns about for CSIFILTK with generic filters.
Two IGGCSI00 calls already return about 2200 names -- one call fills the
64000-byte work area with ~1100 -- so 64 was sweeping a whole catalog per
keystroke for names no screen could show.
Also: `//'<tab>` searched for "*" and "*.*" before the filter check
refused them; it now returns before allocating anything, and tests/run.sh
can compare an EBCDIC build's transcript against a .ebcdic.exp.
|
| |
|
|
|
|
|
| |
A script owns descriptors 0..SYS_NFD-1 and the shell's own live above
them, so filling 3..9 is as far as a script can go; the spawn map keeps
the terminal duplicate reachable past them. The earlier '64' map was
guessing at a case the shell cannot present: back to SYS_NFD+16.
|
| |
|
|
|
|
| |
One 64 KB block, freed before the search returns, and a nested search is
refused rather than given a second one. The second catalog search is
skipped once the candidate list is full.
|
| |
|
|
|
|
|
|
|
| |
The map carried SYS_NFD+16 descriptors, so a script holding more pushed
the terminal's duplicate out of reach and its commands lost the
controlling terminal. 64 leaves room.
`make zos-check` now builds the EBCDIC program too and runs the
character-set tests against it, which nothing did before.
|
| |
|
|
|
|
| |
GCC's -Wformat-truncation is right: the search patterns are built from
the typed word, so check its length first. The pwd.h include went with
the HLQ code it served.
|
| |
|
|
|
|
|
| |
`//NAME` completed against <user>.NAME, which meant assuming a TSO
profile. It now offers nothing: only `//'DSN` and `//DD:` complete.
The quoted member form keeps working, and the tests drop the relative
cases.
|
| |
|
|
|
|
|
|
|
| |
A z/OS terminal is seekable, so stdin was classified as a script: no
prompt, no line editing, no `bind`, just the driver's own echo. Ask
isatty() first; only a non-tty can be seekable.
Found with ~/tmp/tty.c on cbt: on a pty `isatty(0)=1 isatty(2)=1
seek=1`.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
`bind -l` lists the actions the editor can run and `bind
'^[[H'=beginning-of-line` gives one to a key sequence, in the notation
the BSD shells use. Only the names edit_key() already knows are
accepted, so a binding cannot do anything a key could not; `-m` (macro)
is refused rather than ignored. The defaults stay bash's: this is for
people whose .kshrc moves the arrow keys, not a move towards ksh.
`\[` and `\]` in PS1 say "this part does not move the cursor". The
width rule already skips control sequences, so dropping the markers is
the whole implementation, and a coloured prompt now shows its text
instead of the markers.
|