[prev in list] [next in list] [prev in thread] [next in thread] 

List:       coreutils
Subject:    Re: "tee -" treating "-" as stdout violating POSIX?
From:       Bernhard Voelker <mail () bernhard-voelker ! de>
Date:       2015-02-23 0:57:37
Message-ID: 54EA7B01.9060305 () bernhard-voelker ! de
[Download RAW message or body]

On 02/20/2015 08:14 AM, Bernhard Voelker wrote:
> [...], so I'd push the attached v2 unless someone vetoes.

After looking at it again, I found that "tee '-'" skips that
file descriptor when fclose()ing all files.
The following fixes this.

Have a nice day,
Berny

>From 26a37d6368987a5fd712fc2d7572d37a4966f306 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail@bernhard-voelker.de>
Date: Mon, 23 Feb 2015 01:51:59 +0100
Subject: [PATCH] tee: close "-" file

This is a cleanup to the previous commit v8.23-138-g7ceaf1d.

* src/tee.c (tee_files): Do not exempt the "-" file from being closed,
as this is no longer stdout but a normal file.
---
 src/tee.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/tee.c b/src/tee.c
index feb4026..27bd2a4 100644
--- a/src/tee.c
+++ b/src/tee.c
@@ -213,8 +213,7 @@ tee_files (int nfiles, const char **files)

   /* Close the files, but not standard output.  */
   for (i = 1; i <= nfiles; i++)
-    if (!STREQ (files[i], "-")
-        && descriptors[i] && fclose (descriptors[i]) != 0)
+    if (descriptors[i] && fclose (descriptors[i]) != 0)
       {
         error (0, errno, "%s", files[i]);
         ok = false;
-- 
2.1.4


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic