summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-28 14:16:41 -0600
committerGitHub <noreply@github.com>2026-11-28 14:16:41 -0600
commit95d31d2d7d5fd7de81d6d5e2caedcdc369ca0fcf (patch)
tree4959b8d43268945543be4061b8fccd95d04592b1 /tests
parent625908ab56c7c554506d61c83c7001bca19a05f6 (diff)
parent6fe2aff8d6611bf45704ba86120efa23950bfa80 (diff)
downloadzash-95d31d2d7d5fd7de81d6d5e2caedcdc369ca0fcf.tar.gz
Merge pull request #46 from skurtz97/fix/review-2026-11-28
Fixes from the 2026-11-28 code review
Diffstat (limited to 'tests')
-rw-r--r--tests/linux/i-fc-tmpdir.exp11
-rw-r--r--tests/linux/i-fc-tmpdir.sh35
-rw-r--r--tests/linux/i-vi-edit.exp10
-rw-r--r--tests/linux/i-vi-edit.sh44
-rw-r--r--tests/linux/i-vi.exp20
-rw-r--r--tests/linux/i-vi.sh29
-rw-r--r--tests/perf/startup.exp1
-rw-r--r--tests/perf/startup.sh82
-rw-r--r--tests/posix/printf-ext.expbin315 -> 338 bytes
-rw-r--r--tests/posix/printf-ext.sh3
-rw-r--r--tests/posix/trap-midtoken.exp4
-rw-r--r--tests/posix/trap-midtoken.sh18
-rw-r--r--tests/proc/subshell-pure.exp2
-rw-r--r--tests/proc/subshell-pure.sh9
-rwxr-xr-xtests/run.sh4
-rw-r--r--tests/scripts/webdocs.sh4
-rw-r--r--tests/zash/arith-base.exp13
-rw-r--r--tests/zash/arith-base.sh11
-rw-r--r--tests/zash/errtrap-exec.exp10
-rw-r--r--tests/zash/errtrap-exec.sh8
-rw-r--r--tests/zash/lastpipe.exp4
-rw-r--r--tests/zash/lastpipe.sh6
-rw-r--r--tests/zash/subshell-cd.exp2
-rw-r--r--tests/zash/subshell-cd.sh6
-rw-r--r--tests/zash/trim-all.exp13
-rw-r--r--tests/zash/trim-all.sh20
-rw-r--r--tests/zash/ulimit.exp2
-rw-r--r--tests/zash/ulimit.sh4
28 files changed, 366 insertions, 9 deletions
diff --git a/tests/linux/i-fc-tmpdir.exp b/tests/linux/i-fc-tmpdir.exp
new file mode 100644
index 0000000..f0b9bc0
--- /dev/null
+++ b/tests/linux/i-fc-tmpdir.exp
@@ -0,0 +1,11 @@
+$ echo hello
+hello
+$ fc -e "$PWD/ed.sh"
+echo fc-edited
+fc-edited
+$ echo vi-edited
+vi-edited
+$ fc -e 'echo ('
+SHELL: syntax error: unexpected 'WORK/tmp dir$x/zash-fc.XXXX'
+$ exit
+[status 0]
diff --git a/tests/linux/i-fc-tmpdir.sh b/tests/linux/i-fc-tmpdir.sh
new file mode 100644
index 0000000..a6177b0
--- /dev/null
+++ b/tests/linux/i-fc-tmpdir.sh
@@ -0,0 +1,35 @@
+# The editor commands fc and vi's `v` put the temporary file name on a
+# command line, so a TMPDIR with a space and a `$` in it has to survive
+# quoting. Unquoted, the editor got a path cut at the space, and fc ran the
+# original commands again.
+command -v python3 >/dev/null 2>&1 || exit 77
+mkdir -p 'tmp dir$x'
+cat >ed.sh <<'INS'
+#!/bin/sh
+printf 'echo fc-edited\n' >"$1"
+INS
+cat >vis.sh <<'INS'
+#!/bin/sh
+printf 'echo vi-edited\n' >"$1"
+INS
+chmod +x ed.sh vis.sh
+# The syntax error names the temporary file, whose name has the work
+# directory and a random suffix in it: fold both, or the .exp could not be
+# compared.
+{
+TMPDIR="$PWD/tmp dir\$x" PS1='$ ' ENV='' HISTFILE='' VISUAL="$PWD/vis.sh" \
+ python3 "$TESTS/tools/ptydrive.py" "$TSH" -o vi <<'END'
+send echo hello\r
+expect hello
+send fc -e "$PWD/ed.sh"\r
+expect fc-edited
+send echo hi\x1bv\r
+expect vi-edited
+# An editor command that raises an exception must not leave the file
+# behind either: `echo (` is a syntax error, raised past the unlink().
+send fc -e 'echo ('\r
+send exit\r
+END
+} | sed -e "s|$PWD|WORK|g" -e 's/zash-fc\.[A-Za-z0-9]*/zash-fc.XXXX/'
+# Neither editor may leave its file behind.
+ls -A 'tmp dir$x'
diff --git a/tests/linux/i-vi-edit.exp b/tests/linux/i-vi-edit.exp
new file mode 100644
index 0000000..fb8d9c1
--- /dev/null
+++ b/tests/linux/i-vi-edit.exp
@@ -0,0 +1,10 @@
+$ echo visual 'echo one'
+visual echo one
+$ exit
+$ echo edited 'echo two'
+edited echo two
+$ exit
+$ echo keep me
+keep me
+$ exit
+[status 0]
diff --git a/tests/linux/i-vi-edit.sh b/tests/linux/i-vi-edit.sh
new file mode 100644
index 0000000..c78756a
--- /dev/null
+++ b/tests/linux/i-vi-edit.sh
@@ -0,0 +1,44 @@
+# Interactive: vi's `v` puts the line in $VISUAL, else $EDITOR.
+#
+# The editor here is a script that writes the line it was given back as a
+# new command, so the test sees that the editor ran and what it was
+# handed: the line being edited, on its own.
+#
+# `v` runs the editor through eval_string() while the outer command is
+# half parsed, so under `make asan` this is also a regression test for a
+# nested eval that frees the parse arena (see posix/trap-midtoken).
+command -v python3 >/dev/null 2>&1 || exit 77
+cat >ed.sh <<'INS'
+#!/bin/sh
+printf "echo edited '%s'\n" "$(cat "$1")" >"$1"
+INS
+cat >vis.sh <<'INS'
+#!/bin/sh
+printf "echo visual '%s'\n" "$(cat "$1")" >"$1"
+INS
+chmod +x ed.sh vis.sh
+# $VISUAL wins over $EDITOR, as POSIX says.
+PS1='$ ' ENV='' HISTFILE='' EDITOR="$PWD/ed.sh" VISUAL="$PWD/vis.sh" \
+ python3 "$TESTS/tools/ptydrive.py" "$TSH" -o vi <<'END'
+send echo one\x1bv
+send \r
+expect visual echo one
+send exit\r
+END
+# With no $VISUAL, $EDITOR is used.
+PS1='$ ' ENV='' HISTFILE='' VISUAL='' EDITOR="$PWD/ed.sh" \
+ python3 "$TESTS/tools/ptydrive.py" "$TSH" -o vi <<'END'
+send echo two\x1b0wv
+send \r
+expect edited echo two
+send exit\r
+END
+# A failed editor leaves the line alone.
+PS1='$ ' ENV='' HISTFILE='' VISUAL='' EDITOR=false \
+ python3 "$TESTS/tools/ptydrive.py" "$TSH" -o vi <<'END'
+send echo keep me\x1bv
+expect echo keep me
+send \r
+expect keep me
+send exit\r
+END
diff --git a/tests/linux/i-vi.exp b/tests/linux/i-vi.exp
index 6e121ed..891cde4 100644
--- a/tests/linux/i-vi.exp
+++ b/tests/linux/i-vi.exp
@@ -23,5 +23,25 @@ SHELL: ech: not found
$ #echo comment
$ echo done
done
+$ echo def
+def
+$ two three
+SHELL: two: not found
+$ ZZ ZZ two three
+SHELL: ZZ: not found
+$ echo yank
+yank
+$ abcdef
+SHELL: abcdef: not found
+$ echo bdef
+bdef
+$ echo apple
+apple
+$ echo banana
+banana
+$ echo apple
+apple
+$ echo apple
+apple
$ exit
[status 0]
diff --git a/tests/linux/i-vi.sh b/tests/linux/i-vi.sh
index 7e1edaa..d5fb71f 100644
--- a/tests/linux/i-vi.sh
+++ b/tests/linux/i-vi.sh
@@ -25,5 +25,34 @@ expect ech count
send echo comment\x1b#
send echo done\r
expect done
+# `.` repeats the last change, insert mode and all
+send echo abcdef\x1b0wx..\r
+expect echo def
+send echo one two three\x1b0dw.\r
+expect two three
+send echo one two three\x1b0cwZZ\x1bw.\r
+expect ZZ ZZ two three
+# `y` over an empty range, with nothing killed yet: nothing is pasted and
+# no null buffer reaches memcpy (ASan sees that one).
+send \x15echo yank\x1b0y0\r
+expect echo yank
+# ... and a count repeats it that many times, on top of the change's own
+send echo abcdef\x1b0x3.\r
+expect abcdef
+# a motion is not a change: `.` still repeats the last real one
+send echo abcdef\x1b0wx
+send l.
+send \r
+expect echo bdef
+# `/` typed over the previous pattern and backspaced to empty repeats the
+# previous search, not a mix of the two patterns.
+send echo apple\r
+expect apple
+send echo banana\r
+expect banana
+send \x1b/apple\r\r
+expect echo apple
+send \x1b/ban\x7f\x7f\x7f\r\r
+expect echo apple
send exit\r
END
diff --git a/tests/perf/startup.exp b/tests/perf/startup.exp
new file mode 100644
index 0000000..e6aef24
--- /dev/null
+++ b/tests/perf/startup.exp
@@ -0,0 +1 @@
+[status 0]
diff --git a/tests/perf/startup.sh b/tests/perf/startup.sh
new file mode 100644
index 0000000..226d4a9
--- /dev/null
+++ b/tests/perf/startup.sh
@@ -0,0 +1,82 @@
+# Start-up cost: zash's own work before it runs the first command.
+#
+# bench/startup.sh reports the wall time one start costs, and almost all of
+# it is the kernel's fork+exec and the dynamic loader, which are not zash's
+# to fix (/bin/true costs the same 0.44 ms). So this test times the same
+# loop around a trivial program -- the bench clock -- and around zash, and
+# checks the difference: the part of a start that is zash's own init.
+#
+# The target is a gross-regression guard, not a tight one. On Linux the
+# difference is about 20 microseconds, so a few hundred microseconds of
+# headroom keeps a shared machine from failing the run; what it catches is
+# start-up work that should not be there: reading the locale, a file per
+# PATH entry, a large buffer touched at init.
+#
+# Noise only adds time, so each round times $BENCH_N starts (default 200) of
+# zash and then of the clock, and the fastest of $BENCH_R (default 5)
+# differences is reported: what one start costs zash when nothing else is
+# running. A round's difference is the estimator, not two minima from
+# different moments, or the answer always reads zero. The clock wraps its
+# 1000-second window; the difference is corrected for that, as in
+# bench/startup.sh.
+#
+# 77 means the guard cannot run here: no clock built, a wrapped shell
+# (Valgrind), a sanitizer build, or z/OS, where the C run-time's own start
+# dominates every process and bench/startup.sh measures it on the machine.
+
+case $(uname -s) in
+OS/390) exit 77 ;;
+esac
+# Valgrind and the sanitizers time their own overhead, not the shell's.
+case ${ZASH_TEST_WRAP:-} in
+'') ;;
+*) exit 77 ;;
+esac
+case ${TSH:-} in
+*asan* | *mvslint*) exit 77 ;;
+esac
+
+now=${TESTS:-.}/../build/zos-tools/now
+if [ ! -x "$now" ]; then
+ echo "perf/startup: $now is not built; make check builds it" >&2
+ exit 77
+fi
+
+n=${BENCH_N:-200}
+r=${BENCH_R:-5}
+target=${PERF_STARTUP_MAX:-200} # microseconds
+
+# Microseconds for one start of the command given, as the fastest of $r
+# rounds after five warm-up starts. Integer arithmetic, no awk: the bench
+# script says why.
+one_round() {
+ i=0
+ while [ $i -lt 5 ]; do "$@" >/dev/null 2>&1; i=$((i + 1)); done
+ t0=$("$now")
+ i=0
+ while [ $i -lt "$n" ]; do "$@" >/dev/null 2>&1; i=$((i + 1)); done
+ t1=$("$now")
+ d=$((t1 - t0))
+ [ $d -lt 0 ] && d=$((d + 1000000000)) # the clock wrapped its window
+ printf '%d' $((d / n))
+}
+
+over=
+k=0
+while [ $k -lt "$r" ]; do
+ a=$(one_round "$TSH" -c :)
+ b=$(one_round "$now")
+ d=$((a - b))
+ [ $d -lt 0 ] && d=0
+ if [ -z "$over" ] || [ "$d" -lt "$over" ]; then
+ over=$d
+ row="zash $a us, clock $b us"
+ fi
+ k=$((k + 1))
+done
+
+if [ "$over" -gt "$target" ]; then
+ echo "perf/startup: zash added $over us over a trivial program's start"
+ echo "perf/startup: target $target us ($row)"
+ exit 1
+fi
diff --git a/tests/posix/printf-ext.exp b/tests/posix/printf-ext.exp
index a94b9f3..8ddaab7 100644
--- a/tests/posix/printf-ext.exp
+++ b/tests/posix/printf-ext.exp
Binary files differ
diff --git a/tests/posix/printf-ext.sh b/tests/posix/printf-ext.sh
index 60bc69c..066aa2e 100644
--- a/tests/posix/printf-ext.sh
+++ b/tests/posix/printf-ext.sh
@@ -1,6 +1,9 @@
# printf: conversions, widths, escapes and errors.
printf '%5.2f|%-8.3e|%g|%G\n' 3.14159 31415.9 0.0001 1e20
printf '%*d|%-*d|%.*f\n' 6 42 6 42 2 2.71828
+# A negative '*' precision means no precision at all; a negative width
+# is a '-' flag. (It used to build "%.-5jd", which printf rejected.)
+printf '%.*d|%.*s|%*.*f|%0*d|\n' -5 1 -1 abc 3 -2 1.5 -6 42
printf '%c%c%c\n' abc "" z | od -An -c | tr -s ' '
printf '%5c|%-5c|\n' x y
printf '%x %X %o %u %i\n' 255 255 8 42 -7
diff --git a/tests/posix/trap-midtoken.exp b/tests/posix/trap-midtoken.exp
new file mode 100644
index 0000000..067816d
--- /dev/null
+++ b/tests/posix/trap-midtoken.exp
@@ -0,0 +1,4 @@
+trapped
+a b c x
+done
+[status 0]
diff --git a/tests/posix/trap-midtoken.sh b/tests/posix/trap-midtoken.sh
new file mode 100644
index 0000000..8d91bbe
--- /dev/null
+++ b/tests/posix/trap-midtoken.sh
@@ -0,0 +1,18 @@
+# A trap fires while a command is half parsed: the parser must resume the
+# command, not carry on from a freed arena.
+#
+# The writer holds the pipe open and feeds `echo "a b` first. When the
+# shell has started the command it writes its pid, the trap is delivered
+# mid-token, and the rest arrives after the trap has run.
+rm -f pid
+{
+ echo 'trap "echo trapped" USR1'
+ echo 'echo $$ > pid'
+ printf 'echo "a b'
+ while [ ! -s pid ]; do sleep 0.01; done
+ sleep 0.3
+ kill -USR1 "$(cat pid)"
+ sleep 0.3
+ printf ' c" x\n'
+ echo 'echo done'
+} | "$TSH"
diff --git a/tests/proc/subshell-pure.exp b/tests/proc/subshell-pure.exp
index e9b217c..00f8a51 100644
--- a/tests/proc/subshell-pure.exp
+++ b/tests/proc/subshell-pure.exp
@@ -1,4 +1,4 @@
a
done
-zash: spawns=0 forks=1
+zash: spawns=0 forks=0
[status 0]
diff --git a/tests/proc/subshell-pure.sh b/tests/proc/subshell-pure.sh
index d3df23e..0ef7a9e 100644
--- a/tests/proc/subshell-pure.sh
+++ b/tests/proc/subshell-pure.sh
@@ -1,12 +1,11 @@
-# 50 subshells whose body can change nothing outside, then one that has to
-# fork. The counters tell the two apart: `cd` reads the shell's state, so
-# it is not an output-only builtin and keeps its process. The last command
-# is not a subshell, or the shell would become one and never print.
+# 50 subshells whose body can change nothing outside, then two more.
+# cd saves/restores the cwd so it too can run in-process.
+# The counters tell them apart from a real fork.
i=0
while [ $i -lt 50 ]; do
( true )
i=$((i + 1))
done
( echo a )
-( cd /tmp || exit 1 )
+( cd /tmp )
echo done
diff --git a/tests/run.sh b/tests/run.sh
index ab189b7..4df543f 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -10,6 +10,8 @@
# tests/zash/*.sh behaviour specific to zash
# tests/proc/*.sh process accounting: how many spawns and forks a script
# costs (the last line of .exp is the expected count)
+# tests/perf/*.sh performance guards: a start-up cost target, and others
+# that fail when the measured cost is gone (see each file)
# tests/linux/*.sh run only on Linux (error text, /dev/full)
# tests/zos/*.sh run only on z/OS (spawn() and BPX environment)
#
@@ -100,7 +102,7 @@ pass=0
fail=0
skip=0
for t in "$here"/posix/*.sh "$here"/scripts/*.sh "$here"/zash/*.sh \
- "$here"/proc/*.sh "$here/$platform"/*.sh; do
+ "$here"/proc/*.sh "$here"/perf/*.sh "$here/$platform"/*.sh; do
[ -f "$t" ] || continue
case $t in
*.ascii.sh) [ "$ascii" = 1 ] || continue ;;
diff --git a/tests/scripts/webdocs.sh b/tests/scripts/webdocs.sh
index fc4c14e..ce71193 100644
--- a/tests/scripts/webdocs.sh
+++ b/tests/scripts/webdocs.sh
@@ -31,9 +31,9 @@ for d in README:40:README DESIGN:50:Design; do
fi
# The site has a logo, its own contents list and the title, so the
- # document's must be gone.
+ # document's must be gone. A `#` inside a code block is not a title.
if grep -q 'align="center"' "$page" || grep -q '^## Contents$' "$page" ||
- grep -q '^# ' "$page"; then
+ sed '/^```/,/^```/d' "$page" | grep -q '^# '; then
echo "$name header, contents or title still there WRONG"
else
echo "$name header, contents and title dropped ok"
diff --git a/tests/zash/arith-base.exp b/tests/zash/arith-base.exp
index 9fb1dd6..93d4055 100644
--- a/tests/zash/arith-base.exp
+++ b/tests/zash/arith-base.exp
@@ -2,4 +2,17 @@
8
rc=2
arithmetic: bad number base: "1#0"
+rc=2
+arithmetic: bad number base: "99999999999999999999#1"
+rc=2
+arithmetic: bad number: "16# f"
+rc=2
+arithmetic: bad number: "16#0x10"
+rc=2
+arithmetic: bad number: "2#2"
+rc=2
+arithmetic: bad number: "36#zzzzzzzzzzzzzz"
+rc=2
+arithmetic: bad number: "16#"
+35 63 61 62
[status 0]
diff --git a/tests/zash/arith-base.sh b/tests/zash/arith-base.sh
index 5414e08..c361eae 100644
--- a/tests/zash/arith-base.sh
+++ b/tests/zash/arith-base.sh
@@ -5,3 +5,14 @@
"$TSH" -c 'echo $((1#0))' >/dev/null 2>err
echo "rc=$?"
sed 's/^[^:]*: line [0-9]*: //' err
+# A base too large to be a base, a missing digit, and a digit the base
+# does not have are errors, not an overflow trap: the base is built with a
+# bound and every digit is validated against the base.
+for e in '99999999999999999999#1' '16# f' '16#0x10' '2#2' \
+ '36#zzzzzzzzzzzzzz' '16#'; do
+ "$TSH" -c "echo \$(($e))" >/dev/null 2>err
+ echo "rc=$?"
+ sed 's/^[^:]*: line [0-9]*: //' err
+done
+# ksh's digit set: 10-35 are a-z, 36-61 are A-Z, 62 is '@', 63 is '_'.
+"$TSH" -c 'echo $((64#z)) $((64#_)) $((64#Z)) $((64#@))'
diff --git a/tests/zash/errtrap-exec.exp b/tests/zash/errtrap-exec.exp
new file mode 100644
index 0000000..216c976
--- /dev/null
+++ b/tests/zash/errtrap-exec.exp
@@ -0,0 +1,10 @@
+ERR
+[1]
+ERR
+[1]
+ERR
+[1]
+ERR
+BYE
+[1]
+[status 0]
diff --git a/tests/zash/errtrap-exec.sh b/tests/zash/errtrap-exec.sh
new file mode 100644
index 0000000..3acf6e1
--- /dev/null
+++ b/tests/zash/errtrap-exec.sh
@@ -0,0 +1,8 @@
+# The ERR trap runs for the last command too. A failing external command
+# as the last thing a shell runs is exec'd, and the shell is gone before
+# the trap could run, unless the trap holds that shortcut back. So does a
+# subshell that would otherwise run in the parent.
+"$TSH" -c 'trap "echo ERR" ERR; /bin/false'; echo "[$?]"
+"$TSH" -c 'trap "echo ERR" ERR; false'; echo "[$?]"
+"$TSH" -c 'trap "echo ERR" ERR; (/bin/false)'; echo "[$?]"
+"$TSH" -c 'trap "echo ERR" ERR; trap "echo BYE" EXIT; /bin/false'; echo "[$?]"
diff --git a/tests/zash/lastpipe.exp b/tests/zash/lastpipe.exp
index 3c90f80..3107620 100644
--- a/tests/zash/lastpipe.exp
+++ b/tests/zash/lastpipe.exp
@@ -10,4 +10,8 @@ assigned-in-stage
[unset]
[unset] [last]
set
+SCRIPT: line 16: boom: fatal
+after fatal: 2
+SCRIPT: line 19: syntax error: unexpected 'end of file'
+after syntax: 2
[status 3]
diff --git a/tests/zash/lastpipe.sh b/tests/zash/lastpipe.sh
index ba17500..4e93845 100644
--- a/tests/zash/lastpipe.sh
+++ b/tests/zash/lastpipe.sh
@@ -11,4 +11,10 @@ q=1; q=2 | true; echo $q
echo "${m=assigned-in-stage}" | cat; echo "[${m-unset}]"
: "${k=assigned-in-last}" | : "${k2=last}"; echo "[${k-unset}] [${k2-unset}]"
f() { fv=set; }; echo | f; echo $fv
+# A fatal error in the last stage ends that stage, not the script: ksh93
+# and dash both run on. The `exit` below is the one that does not.
+echo a | echo "${boom:?fatal}"
+echo "after fatal: $?"
+echo a | eval '('
+echo "after syntax: $?"
echo skip | exit 3; echo "exit in last stage exits: no"
diff --git a/tests/zash/subshell-cd.exp b/tests/zash/subshell-cd.exp
new file mode 100644
index 0000000..4614f0f
--- /dev/null
+++ b/tests/zash/subshell-cd.exp
@@ -0,0 +1,2 @@
+ok
+[status 0]
diff --git a/tests/zash/subshell-cd.sh b/tests/zash/subshell-cd.sh
new file mode 100644
index 0000000..7bc7a04
--- /dev/null
+++ b/tests/zash/subshell-cd.sh
@@ -0,0 +1,6 @@
+# ( cd dir ) must restore the working directory and PWD.
+dir=$PWD
+( cd / )
+test "$PWD" = "$dir" || { echo "PWD not restored"; exit 1; }
+test "$(pwd)" = "$dir" || { echo "cwd not restored"; exit 1; }
+echo ok
diff --git a/tests/zash/trim-all.exp b/tests/zash/trim-all.exp
new file mode 100644
index 0000000..0380161
--- /dev/null
+++ b/tests/zash/trim-all.exp
@@ -0,0 +1,13 @@
+<c><d>
+<c><d>
+<c d>
+<c><d>
+<ab><abd>
+<abc><>
+<c><d>
+<b><c>
+<b><c>
+<a b a>
+[]
+<ne:two>
+[status 0]
diff --git a/tests/zash/trim-all.sh b/tests/zash/trim-all.sh
new file mode 100644
index 0000000..1b45bf2
--- /dev/null
+++ b/tests/zash/trim-all.sh
@@ -0,0 +1,20 @@
+# `${@#pat}` and `${*#pat}`: the trim applies to each positional parameter,
+# and then the usual `"$@"` / `"$*"` rules decide the fields. ksh93 and
+# bash agree on every line, which is where the expectations come from.
+set -- abc abd
+printf "<%s>" "${@#ab}"; echo
+printf "<%s>" ${@#ab}; echo
+printf "<%s>" "${*#ab}"; echo
+printf "<%s>" ${*#ab}; echo
+printf "<%s>" "${@%c}"; echo
+printf "<%s>" "${@%%*d}"; echo
+printf "<%s>" "${@##a*b}"; echo
+set -- "a b" "a c"
+printf "<%s>" "${@#a }"; echo
+printf "<%s>" ${@#a\ }; echo
+printf "<%s>" "${*% c}"; echo
+set --
+printf "[%s]" "${@#a}"; echo
+set -- one two
+IFS=:
+printf "<%s>" "${*#o}"; echo
diff --git a/tests/zash/ulimit.exp b/tests/zash/ulimit.exp
index 75ed7d8..11fbc2f 100644
--- a/tests/zash/ulimit.exp
+++ b/tests/zash/ulimit.exp
@@ -9,4 +9,6 @@ same
status=2
status=2
0
+status=1
+ulimit: 18014398509481984: limit out of range
[status 0]
diff --git a/tests/zash/ulimit.sh b/tests/zash/ulimit.sh
index a00c2f6..a335e37 100644
--- a/tests/zash/ulimit.sh
+++ b/tests/zash/ulimit.sh
@@ -9,3 +9,7 @@ ulimit -a | grep -c -- '-n)'
ulimit -Z 2>/dev/null; echo "status=$?"
ulimit -n abc 2>/dev/null; echo "status=$?"
(ulimit -c 0; ulimit -c)
+# A limit whose byte count does not fit rlim_t is refused, not wrapped to
+# zero: 2^54 kbytes is 2^64 bytes, and it used to become a 0-byte stack.
+(ulimit -s 18014398509481984) 2>err; echo "status=$?"
+sed 's/^[^:]*: line [0-9]*: //' err