* Ex does not exit on errors immediately anymore if standard input is not

a terminal but a pipe or regular file.
This commit is contained in:
Gunnar Ritter 2005-02-17 17:00:56 +00:00
parent 50bf5781f9
commit aada6fd740
5 changed files with 22 additions and 10 deletions

View File

@ -17,8 +17,8 @@ Release ...
* The argument to the -w option is correctly recognized now.
* If the SHELL environment variable is set to the empty string, it is now
ignored.
* A non-null exit status is now returned if a file could not be opened, or
if an invalid address is given for a command.
* A non-null exit status is now returned if a file could not be opened, if
an invalid address is given for a command, or if a tag is not found.
* If the match for a substitution is of length zero, a line overflow is
now avoided when compiled with the 'UNIX(R) Regular Expression Library'.
* When moving left while the cursor is positioned over a multicolumn
@ -37,6 +37,8 @@ Release ...
printed lines anymore.
* The 'source' ex command now works if command input comes from a pipe or
regular file.
* Ex does not exit on errors immediately anymore if standard input is not
a terminal but a pipe or regular file.
Release 1/19/05
* The last release erroneously made 'X' work like 'x' in visual mode. It now

3
ex.h
View File

@ -72,7 +72,7 @@
*
* from ex.h 7.7.1.1 (Berkeley) 8/12/86
*
* @(#)ex.h 1.52 (gritter) 2/17/05
* @(#)ex.h 1.53 (gritter) 2/17/05
*/
/*
@ -438,6 +438,7 @@ var JMP_BUF vreslab; /* For error throws to a visual catch */
var bool writing; /* 1 if in middle of a file write */
var int xchng; /* Suppresses multiple "No writes" in !cmd */
var int failed; /* exit with a non-zero status */
var int exitoneof; /* exit command loop on EOF */
/*
* Macros

View File

@ -73,7 +73,7 @@
#ifndef lint
#ifdef DOSCCS
static char sccsid[] = "@(#)ex_cmds.c 1.18 (gritter) 1/2/05";
static char sccsid[] = "@(#)ex_cmds.c 1.20 (gritter) 2/17/05";
#endif
#endif
@ -97,7 +97,7 @@ int poffset;
* processing and call command routines to do the real work.
*/
void
commands(int noprompt, int exitoneof)
commands(int noprompt, int _exitoneof)
{
register line *addr;
register int c;
@ -110,6 +110,7 @@ commands(int noprompt, int exitoneof)
resetflav();
nochng();
for (;;) {
exitoneof = _exitoneof;
/*
* If dot at last command
* ended up at zero, advance to one if there is a such.
@ -834,8 +835,11 @@ wq:
c = getchar();
if (c=='\n' || c=='\r')
ungetchar(c);
if (any(c, "@*\n\r"))
if (any(c, "@*\n\r")) {
c = lastmac;
if (c == 0)
failed = 1;
}
if (isupper(c))
c = tolower(c);
if (!islower(c))

View File

@ -73,7 +73,7 @@
#ifndef lint
#ifdef DOSCCS
static char sccsid[] = "@(#)ex_cmds2.c 1.17 (gritter) 12/1/04";
static char sccsid[] = "@(#)ex_cmds2.c 1.18 (gritter) 2/17/05";
#endif
#endif
@ -157,7 +157,7 @@ error0(void)
dingdong();
return;
}
if (input) {
if (input && exitoneof) {
input = strend(input) - 1;
if (*input == '\n')
setlastchar('\n');
@ -218,7 +218,8 @@ error1(char *str)
putNFL();
if (die)
exitex(1);
lseek(0, (off_t)0, SEEK_END);
if (exitoneof)
lseek(0, (off_t)0, SEEK_END);
if (inglobal)
setlastchar('\n');
while (lastchar() != '\n' && lastchar() != EOF)

View File

@ -73,7 +73,7 @@
#ifndef lint
#ifdef DOSCCS
static char sccsid[] = "@(#)ex_cmdsub.c 1.27 (gritter) 2/17/05";
static char sccsid[] = "@(#)ex_cmdsub.c 1.28 (gritter) 2/17/05";
#endif
#endif
@ -561,6 +561,7 @@ tagfind(bool quick)
char *fn, *fne;
struct stat sbuf;
char *savefirstpat = NULL;
int ofailed;
#ifdef FASTTAG
int ft_iof;
char ft_iofbuf[MAXBSIZE];
@ -570,6 +571,8 @@ tagfind(bool quick)
omagic = value(MAGIC);
owrapscan = value(WRAPSCAN);
ofailed = failed;
failed = 1;
if (!skipend()) {
register char *lp = lasttag;
@ -752,6 +755,7 @@ badtags:
if (tflag)
value(WRAPSCAN) = 1;
commands(1, 1);
failed = ofailed;
peekc = d;
globp = oglobp;
value(MAGIC) = omagic;