Restore apb's 20140820 commit (-r1.228 of main.c):

It should not be an error to have VAR != command that prints no output

Joerg reverted a bit too enthusiastically.
This commit is contained in:
dholland 2014-09-09 06:18:17 +00:00
parent 4c77e4366f
commit 3728c0fad2
1 changed files with 9 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.230 2014/09/07 20:55:34 joerg Exp $ */
/* $NetBSD: main.c,v 1.231 2014/09/09 06:18:17 dholland Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: main.c,v 1.230 2014/09/07 20:55:34 joerg Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.231 2014/09/09 06:18:17 dholland Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: main.c,v 1.230 2014/09/07 20:55:34 joerg Exp $");
__RCSID("$NetBSD: main.c,v 1.231 2014/09/09 06:18:17 dholland Exp $");
#endif
#endif /* not lint */
#endif
@ -1488,10 +1488,12 @@ Cmd_Exec(const char *cmd, const char **errnum)
int status; /* command exit status */
Buffer buf; /* buffer to store the result */
char *cp;
int cc;
int cc; /* bytes read, or -1 */
int savederr; /* saved errno */
*errnum = NULL;
savederr = 0;
if (!shellName)
Shell_Init();
@ -1554,6 +1556,8 @@ Cmd_Exec(const char *cmd, const char **errnum)
Buf_AddBytes(&buf, cc, result);
}
while (cc > 0 || (cc == -1 && errno == EINTR));
if (cc == -1)
savederr = errno;
/*
* Close the input side of the pipe.
@ -1570,7 +1574,7 @@ Cmd_Exec(const char *cmd, const char **errnum)
cc = Buf_Size(&buf);
res = Buf_Destroy(&buf, FALSE);
if (cc == 0)
if (savederr != 0)
*errnum = "Couldn't read shell's output for \"%s\"";
if (WIFSIGNALED(status))