<feed xmlns='http://www.w3.org/2005/Atom'>
<title>zash.git/src/edit_builtin.c, 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>Fix z/OS 64-bit linkage/storage, EBCDIC, editor, and checkout issues</title>
<updated>2026-11-29T03:58:27Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-29T03:58:27Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=b97207f7e5dd3d8d147da525ede1ba3609f5c983'/>
<id>urn:sha1:b97207f7e5dd3d8d147da525ede1ba3609f5c983</id>
<content type='text'>
- 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.
</content>
</entry>
<entry>
<title>fix(edit): vi search reads its pattern into a buffer of its own</title>
<updated>2026-11-28T06:39:28Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-28T06:39:28Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=95bf87d4ed037e6d6786cc395d94dbe44ee88e32'/>
<id>urn:sha1:95bf87d4ed037e6d6786cc395d94dbe44ee88e32</id>
<content type='text'>
`/` 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.
</content>
</entry>
<entry>
<title>fix(edit): quote the temporary file name for the editor</title>
<updated>2026-11-28T06:37:39Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-28T06:37:39Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=d538cc8ce9c32c932e12134b7bd59a88e88d748c'/>
<id>urn:sha1:d538cc8ce9c32c932e12134b7bd59a88e88d748c</id>
<content type='text'>
`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.
</content>
</entry>
<entry>
<title>fix(edit): vi `y` keeps the line and never pastes the old kill</title>
<updated>2026-11-28T06:30:30Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-28T06:30:30Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=56bd0e6c2ab87ab140cef35882cff52153f36b7c'/>
<id>urn:sha1:56bd0e6c2ab87ab140cef35882cff52153f36b7c</id>
<content type='text'>
`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.
</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>interactive: one editor, no library</title>
<updated>2026-11-26T03:54:08Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-26T03:54:08Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=87c6a0f8f822c57b4f63bc8bb099a33307871414'/>
<id>urn:sha1:87c6a0f8f822c57b4f63bc8bb099a33307871414</id>
<content type='text'>
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).
</content>
</entry>
<entry>
<title>interactive: completion works in the libedit build too</title>
<updated>2026-11-26T03:44:25Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-26T03:44:25Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=5364f98dff13a4bc9202a14bc5f9146436366039'/>
<id>urn:sha1:5364f98dff13a4bc9202a14bc5f9146436366039</id>
<content type='text'>
The libedit editor had no Tab binding at all, so the same line typed in
the two builds behaved differently: `myalias&lt;Tab&gt;` 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.
</content>
</entry>
<entry>
<title>interactive: a prompt's width counts columns, not bytes</title>
<updated>2026-11-26T02:30:22Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-26T02:30:22Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=deb0ed011fe2cfc7058facb3f63b7feaeb8d4a8e'/>
<id>urn:sha1:deb0ed011fe2cfc7058facb3f63b7feaeb8d4a8e</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>C23: nullptr for null pointers, constexpr for typed constants</title>
<updated>2026-11-25T06:31:26Z</updated>
<author>
<name>Sean Kurtz</name>
<email>seankurtz75@gmail.com</email>
</author>
<published>2026-11-25T06:30:44Z</published>
<link rel='alternate' type='text/html' href='https://git.abendless.com/zash.git/commit/?id=c7f23b8a5fb86f8df51809aca64415bcadcaa9f6'/>
<id>urn:sha1:c7f23b8a5fb86f8df51809aca64415bcadcaa9f6</id>
<content type='text'>
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.
</content>
</entry>
</feed>
