| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`/` 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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 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.
|
| |
|
|
|
|
|
| |
`//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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
`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.
|
| |
|
|
|
|
|
|
| |
meta-u, meta-l and meta-c change the case of a word, meta-t transposes
the words either side of the cursor, meta-. inserts the last word of the
previous line and meta-\\ collapses the blanks around the cursor. The
rest of the map was already bash's: a BSD sh or a bash prompt is the
target, not ksh's.
|
| |
|
|
|
|
|
|
| |
A login shell reads /etc/profile before ~/envfile, and a distribution's
copy is bash-flavoured: it fails on a substitution only bash accepts and
it sets USER from the account database, so \u printed the real user. The
ENV file now sets USER back, and the host's own diagnostic is dropped
from the transcript.
|
| |
|
|
|
|
|
|
|
|
|
| |
A failing line in $ENV ended the shell: run_input() only installed its
recovering handler for the main loop, so sh_error() found no handler and
called exit_shell(). An interactive shell must not exit for a command
that fails (POSIX 2.5.3), and a .kshrc shared with ksh is full of lines
zash rejects.
Startup files now run with RI_RECOVER, which recovers from an error
without printing a prompt, and the rest of the file is still read.
|
| |
|
|
|
|
|
| |
POSIX: ENV is parameter-expanded, and not used when the real and
effective user or group IDs differ. The expansion reuses the prompt's
contained expansion (expand_quietly), so a bad ENV cannot unwind into
startup. $HOME/.profile is not sourced if the path would be truncated.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
New groups: tests/scripts (integration, expectations from dash) and
z/OS data set, tso, EBCDIC and tagging tests with Linux stand-ins.
|
| |
|
|
|
|
|
|
| |
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.
|
|
|
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.
|