[libvirt] [PATCH 2/2] [TCK] nwfilter: Add test cases for ipset

Eric Blake eblake at redhat.com
Fri Apr 27 12:33:04 UTC 2012


On 04/27/2012 05:12 AM, Stefan Berger wrote:
> On 04/26/2012 05:13 PM, Eric Blake wrote:
>> On 04/23/2012 06:20 AM, Stefan Berger wrote:
>>
>>
>>> +  if [ -n "${cmd}" ]; then
>>> +    eval "${cmd}" 2>&1 1>/dev/null
>> This says output any errors from command to our stdout, and to ignore
>> normal output of $cmd.  Is that what you meant, or did you want to
>> ignore both output and errors from $cmd, in which case you should swap
>> the redirection operators?
> 
> The intention was to not get any output from running those test
> commands. Above unfortunately only solved this for stdout but not for
> suppressing stderr, so 'ipset: command not found' was still printed. Now
> I changed this line to
> 
> eval "${cmd}" 2>/dev/null 1>/dev/null
> 
> and everything is quiet. Not quite sure why the previous notation didn't
> work...

Using '2>&1 1>/dev/null' says:

start with stdout (1) and stderr (2) inherited from the parent
change fd 2 to be copied from the current fd 1 (the parents stdout)
change fd 1 to be /dev/null
now the child discards output, and sends errors into the parent's stdout

Using '2>/dev/null 1>/dev/null' says:
start with stdout and stderr inherited from the parent
change fd 2 to be /dev/null
change fd 1 to be /dev/null
now the child discards everything

Swapping the order, and using '>/dev/null 2>&1' says:
start with stdout (1) and stderr (2) inherited from the parent
change fd 1 to be /dev/null
change fd 2 to be copied from the current fd 1 (/dev/null)
now the child discards everything

In other words, all you did wrong was forgetting that redirections are
honored left-to-right.

> I will post a V2. For this patch to go in I'll also need an ACK
> for the somewhat longer patch for ipset support:
> 
> http://www.redhat.com/archives/libvir-list/2012-April/msg01226.html

Yep, on my list to review.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120427/cd7e185c/attachment-0001.sig>


More information about the libvir-list mailing list