From be9e8bfaea0093d7612b7ee5b357c5f70f1b7463 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Mon, 3 Jul 2017 15:54:44 +0000 Subject: [PATCH] ed(1): Allow the omission of one address in (.,.) and (.;.) address ranges With this patch, ",n" is an abbreviation for "1,n", ";n" abbreviates ".;n". The "n," and "n;" variants mean "n,n" and "n;n", respectively. Also, piping to a shell command does not count as a save, so don't reset the modified flag. Obtained from: OpenBSD (CVS Rev. 1.58, 1.59) --- bin/ed/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/ed/main.c b/bin/ed/main.c index 6cb7d03364d0..babffa813088 100644 --- a/bin/ed/main.c +++ b/bin/ed/main.c @@ -350,7 +350,8 @@ next_addr(void) ibufp++; addr_cnt++; second_addr = (c == ';') ? current_addr : 1; - addr = addr_last; + if ((addr = next_addr()) < 0) + addr = addr_last; break; } /* FALLTHROUGH */ @@ -809,7 +810,7 @@ exec_command(void) if ((addr = write_file(*fnp ? fnp : old_filename, (c == 'W') ? "a" : "w", first_addr, second_addr)) < 0) return ERR; - else if (addr == addr_last) + else if (addr == addr_last && *fnp != '!') modified = 0; else if (modified && !scripted && n == 'q') gflag = EMOD;