diff options
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 23 |
1 files changed, 11 insertions, 12 deletions
@@ -131,10 +131,9 @@ wrerror: /* otherwise die verbosely */ - if ( (rp != NULL && (rp->flag & RED_NON_FATAL) != 0) - || is_non_fatal_std(fp)) { + if ((rp != NULL) ? is_non_fatal_redirect(rp->value) : is_non_fatal_std(fp)) update_ERRNO_int(errno); - } else + else fatal(_("%s to \"%s\" failed (%s)"), from, rp ? rp->value : _("standard output"), errno ? strerror(errno) : _("reason unknown")); @@ -1649,7 +1648,7 @@ do_printf(int nargs, int redirtype) redir_exp = TOP(); if (redir_exp->type != Node_val) fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp)); - rp = redirect(redir_exp, redirtype, & errflg); + rp = redirect(redir_exp, redirtype, & errflg, true); DEREF(redir_exp); decr_sp(); } @@ -1662,7 +1661,7 @@ do_printf(int nargs, int redirtype) redir_exp = PEEK(nargs); if (redir_exp->type != Node_val) fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp)); - rp = redirect(redir_exp, redirtype, & errflg); + rp = redirect(redir_exp, redirtype, & errflg, true); if (rp != NULL) fp = rp->output.fp; else if (errflg) { @@ -2093,7 +2092,7 @@ do_print(int nargs, int redirtype) redir_exp = PEEK(nargs); if (redir_exp->type != Node_val) fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp)); - rp = redirect(redir_exp, redirtype, & errflg); + rp = redirect(redir_exp, redirtype, & errflg, true); if (rp != NULL) fp = rp->output.fp; else if (errflg) { @@ -2161,7 +2160,7 @@ do_print_rec(int nargs, int redirtype) assert(nargs == 0); if (redirtype != 0) { redir_exp = TOP(); - rp = redirect(redir_exp, redirtype, & errflg); + rp = redirect(redir_exp, redirtype, & errflg, true); if (rp != NULL) fp = rp->output.fp; DEREF(redir_exp); @@ -2169,17 +2168,17 @@ do_print_rec(int nargs, int redirtype) } else fp = output_fp; + if (errflg) { + update_ERRNO_int(errflg); + return; + } + if (fp == NULL) return; if (! field0_valid) (void) get_field(0L, NULL); /* rebuild record */ - if (errflg) { - update_ERRNO_int(errflg); - return; - } - f0 = fields_arr[0]; if (do_lint && (f0->flags & NULL_FIELD) != 0) |