[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tee: add option for outputting to stderr
From: |
Peter Berbec |
Subject: |
[PATCH] tee: add option for outputting to stderr |
Date: |
Wed, 18 Jan 2017 18:02:25 -0500 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 |
When writing scripts, the ability to send something to stdout and stderr
sometimes comes up. I have written a patch to tee.c adding an option for
this.
Peter Berbec
47a48,50
/* If true, output to stderr as well */
static bool out_to_error;
61a65
{"error", no_argument, NULL, 'e'},
92a97
-e, --error also output to stderr. negates -p\n\\
132a138
out_to_error = false;
134c140
< while ((optc = getopt_long (argc, argv, "aip", long_options, NULL)) != -1)
---
while ((optc = getopt_long (argc, argv, "aeip", long_options, NULL)) != -1)
137a144,147
case 'e':
out_to_error = true;
break;
162a173,175
if (out_to_error && output_error)
output_error = output_error_sigpipe;
207c220
< descriptors = xnmalloc (nfiles + 1, sizeof *descriptors);
---
descriptors = xnmalloc (nfiles + (out_to_error?2:1), sizeof *descriptors);
231a245,252
if (out_to_error)
{
descriptors[i] = stderr;
files[i] = bad_cast (_("standard error"));
setvbuf (stderr, NULL, _IONBF, 0);
n_outputs++;
}
250a272,273
if (descriptors[i] == stderr)
clearerr (stdout); /* Avoid redundant close_stderr diagnostic. */