aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2017-03-24 10:06:53 +0300
committerArnold D. Robbins <arnold@skeeve.com>2017-03-24 10:06:53 +0300
commit95c4e8223bb8115488662a7cf2ee2632bc5c6a18 (patch)
tree11a354d000e23af230a4c2221634cd8f1de3802b /builtin.c
parentf0a99fcb278d35d28d7dd92c92cf13c05b5fbb81 (diff)
parentbc97284df48d79d57450aae746c08f8d55d3a57a (diff)
downloadegawk-95c4e8223bb8115488662a7cf2ee2632bc5c6a18.tar.gz
egawk-95c4e8223bb8115488662a7cf2ee2632bc5c6a18.tar.bz2
egawk-95c4e8223bb8115488662a7cf2ee2632bc5c6a18.zip
Merge branch 'master' into feature/stringfix
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/builtin.c b/builtin.c
index 3c69ad1a..fba23926 100644
--- a/builtin.c
+++ b/builtin.c
@@ -131,14 +131,18 @@ wrerror:
#endif
/* die silently on EPIPE to stdout */
if (fp == stdout && errno == EPIPE)
- gawk_exit(EXIT_FATAL);
+ gawk_exit(EXIT_SUCCESS); // a la SIGPIPE
/* otherwise die verbosely */
if ((rp != NULL) ? is_non_fatal_redirect(rp->value, strlen(rp->value)) : is_non_fatal_std(fp))
update_ERRNO_int(errno);
else
fatal(_("%s to \"%s\" failed (%s)"), from,
- rp ? rp->value : _("standard output"),
+ rp != NULL
+ ? rp->value
+ : fp == stdout
+ ? _("standard output")
+ : _("standard error"),
errno ? strerror(errno) : _("reason unknown"));
}
@@ -214,7 +218,7 @@ do_fflush(int nargs)
/* fflush() */
if (nargs == 0) {
- status = flush_io();
+ status = flush_io(); // ERRNO updated
return make_number((AWKNUM) status);
}
@@ -224,7 +228,7 @@ do_fflush(int nargs)
/* fflush("") */
if (tmp->stlen == 0) {
- status = flush_io();
+ status = flush_io(); // ERRNO updated
DEREF(tmp);
return make_number((AWKNUM) status);
}
@@ -251,6 +255,7 @@ do_fflush(int nargs)
if (! is_non_fatal_redirect(tmp->stptr, tmp->stlen))
fatal(_("fflush: cannot flush file `%.*s': %s"),
len, file, strerror(errno));
+ update_ERRNO_int(errno);
}
} else if ((rp->flag & RED_TWOWAY) != 0)
warning(_("fflush: cannot flush: two-way pipe `%.*s' has closed write end"),