From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5757 invoked from network); 4 Feb 2002 18:45:47 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 4 Feb 2002 18:45:47 -0000 Received: (qmail 2277 invoked by alias); 4 Feb 2002 18:45:41 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16556 Received: (qmail 2266 invoked from network); 4 Feb 2002 18:45:40 -0000 From: "Bart Schaefer" Message-Id: <1020204184533.ZM24919@candle.brasslantern.com> Date: Mon, 4 Feb 2002 18:45:33 +0000 In-Reply-To: <20020131064103.12082.qmail@web10405.mail.yahoo.com> Comments: In reply to Felix Rosencrantz "Test failure in redirect." (Jan 30, 10:41pm) References: <20020131064103.12082.qmail@web10405.mail.yahoo.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Felix Rosencrantz , zsh-workers@sunsite.dk Subject: Re: Test failure in redirect. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jan 30, 10:41pm, Felix Rosencrantz wrote: } Subject: Test failure in redirect. } } print foo >&- } Error output: } (eval):print:1: write error: bad file descriptor This is of course a result of the error-checking that Clint added to bin_print(). --- ../zsh-forge/current/Src/builtin.c Sun Jan 27 15:17:26 2002 +++ Src/builtin.c Mon Feb 4 10:43:46 2002 @@ -3074,10 +3074,12 @@ } while (*ap); fputc(ops['N'] ? '\0' : '\n', fout); } - if (((fout != stdout) ? fclose(fout) : fflush(fout)) != 0) { + /* Testing EBADF special-cases >&- redirections */ + if ((fout != stdout) ? (fclose(fout) != 0) : + (fflush(fout) != 0 && errno != EBADF)) { zwarnnam(name, "write error: %e", NULL, errno); ret = 1; - } + } return ret; } @@ -3090,11 +3092,12 @@ } if (!(ops['n'] || nnl)) fputc(ops['N'] ? '\0' : '\n', fout); - if (((fout != stdout) ? fclose(fout) : fflush(fout)) != 0) { + /* Testing EBADF special-cases >&- redirections */ + if ((fout != stdout) ? (fclose(fout) != 0) : + (fflush(fout) != 0 && errno != EBADF)) { zwarnnam(name, "write error: %e", NULL, errno); ret = 1; } - return ret; } @@ -3279,9 +3282,11 @@ } zwarnnam(name, "%s: invalid directive", start, 0); if (*c) c[1] = save; - if (((fout != stdout) ? fclose(fout) : fflush(fout)) != 0) { - zwarnnam(name, "write error: %e", NULL, errno); - } + /* Testing EBADF special-cases >&- redirections */ + if ((fout != stdout) ? (fclose(fout) != 0) : + (fflush(fout) != 0 && errno != EBADF)) { + zwarnnam(name, "write error: %e", NULL, errno); + } return 1; } @@ -3345,9 +3350,11 @@ /* if there are remaining args, reuse format string */ } while (*args && args != first && !ops['r']); - if (((fout != stdout) ? fclose(fout) : fflush(fout)) != 0) { - zwarnnam(name, "write error: %e", NULL, errno); - ret = 1; + /* Testing EBADF special-cases >&- redirections */ + if ((fout != stdout) ? (fclose(fout) != 0) : + (fflush(fout) != 0 && errno != EBADF)) { + zwarnnam(name, "write error: %e", NULL, errno); + ret = 1; } return ret; } -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net