ed: Allow z commands with no address - sbase - suckless unix tools
HTML git clone git://git.suckless.org/sbase
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit ae50e31d532df74e97d2e0525d0f282cf3377142
DIR parent 0190f5e7bf8985af3ed768f7d17d192c23beb5d1
HTML Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Mon, 8 Dec 2025 17:01:30 +0100
ed: Allow z commands with no address
When a single z commit is executed then nlines == 0, and
we don't have a value for the line where scroll and this
is why we have to call deflines() to setup the default
value.
Diffstat:
M ed.c | 3 ++-
A tests/0006-ed.sh | 14 ++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
---
DIR diff --git a/ed.c b/ed.c
@@ -1385,13 +1385,14 @@ repeat:
join();
break;
case 'z':
- if (nlines != 1)
+ if (nlines > 1)
goto bad_address;
if (isdigit(back(input())))
num = getnum();
else
num = 24;
chkprint(1);
+ deflines(curln, curln);
scroll(num);
break;
case 'k':
DIR diff --git a/tests/0006-ed.sh b/tests/0006-ed.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+../ed <<EOF | (read a && read b && test $a-$b == 1-2)
+0a
+1
+2
+3
+4
+5
+6
+.
+1z1
+z1
+EOF