coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH 1/2] tee: exit early if no more writable outputs


From: Pádraig Brady
Subject: Re: [PATCH 1/2] tee: exit early if no more writable outputs
Date: Tue, 17 Feb 2015 10:27:50 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

On 17/02/15 08:26, Bernhard Voelker wrote:
> On 02/17/2015 08:36 AM, Bernhard Voelker wrote:
>> On 02/17/2015 03:44 AM, Pádraig Brady wrote:
>>> +  yes | returns_ 1 timeout 10 tee /dev/full 2>err >/dev/full || fail=1
>>
>> This test case combines 2 test cases, i.e., when writing to the output
>> file *and* to stdout is returning an error:
>>
>>   $ yes |  timeout 10 src/tee /dev/full > /dev/full ; echo $?
>>   src/tee: standard output: No space left on device
>>   src/tee: /dev/full: No space left on device
>>   1
>>
>> But if run separately, then we run into timeouts again:
>>
>>   $ yes |  timeout 10 src/tee /dev/null > /dev/full; echo $?
>>   src/tee: standard output: No space left on device
>>   124
>>
>>   $ yes |  timeout 10 src/tee /dev/full > /dev/null; echo $?
>>   src/tee: /dev/full: No space left on device
>>   124
>>
>> Isn't exiting early in both cases what you wanted to achieve?
> 
> Oho, read this [0]:
> 
>   CONSEQUENCES OF ERRORS
> 
>   If a write to any successfully opened file operand fails, writes
>   to other successfully opened file operands and standard output
>   shall continue, but the exit status shall be non-zero. [...]
> 
> Therefore your patch is right; only the test case doesn't cover the
> case where tee has to continue if any of the output files or stdout
> can still be written.
> 
> [0]
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/tee.html

The following patch wrt --write-error, tests the continue
with working outputs functionality.  Though that's with pipes
and only with the new option.  I've amended the test in this patch
to check continuation with standard files and no options, like:

+  # Ensure we continue with outputs that are OK
+  seq 10000 > multi_read || framework_failure_
+
+  returns_ 1 tee /dev/full 2>err >multi_write <multi_read || fail=1
+  cmp multi_read multi_write || fail=1
+  # Ensure an error for failing output
+  test $(wc -l < err) = 1 || { cat err; fail=1; }
+
+  returns_ 1 tee multi_write 2>err >/dev/full <multi_read || fail=1
+  cmp multi_read multi_write || fail=1
+  # Ensure an error for failing output
+  test $(wc -l < err) = 1 || { cat err; fail=1; }

thanks,
Pádraig.



reply via email to

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