coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "tee -" treating "-" as stdout violating POSIX?


From: Bernhard Voelker
Subject: Re: "tee -" treating "-" as stdout violating POSIX?
Date: Mon, 23 Feb 2015 01:57:37 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

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 <address@hidden>
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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]