ed: Accept no address in k command - sbase - suckless unix tools
(HTM) git clone git://git.suckless.org/sbase
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit a45474cfbb2de4a16592bf4fa7e19345cab03c5c
(DIR) parent f6a1fbb9b1c6b5058371daeeb903a7e7a3643bbd
(HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Mon, 8 Dec 2025 18:03:44 +0100
ed: Accept no address in k command
Diffstat:
M ed.c | 2 +-
A tests/0009-ed.sh | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/ed.c b/ed.c
@@ -1402,7 +1402,7 @@ repeat:
scroll(num);
break;
case 'k':
- if (nlines != 1)
+ if (nlines > 1)
goto bad_address;
if (!islower(c = input()))
error("invalid mark character");
(DIR) diff --git a/tests/0009-ed.sh b/tests/0009-ed.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+ed -s /dev/null <<EOF | (read a && test $a == 1)
+a
+1
+2
+3
+4
+5
+6
+7
+8
+9
+.
+1s/^//
+ka
+9s/^//
+'a
+w
+EOF