1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-24 07:40:52 +00:00

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)
This commit is contained in:
Pedro F. Giffuni 2017-07-03 15:54:44 +00:00
parent 5567474c4a
commit be9e8bfaea
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=320603

View File

@ -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;