findutils-patches
[Top][All Lists]
Advanced

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

Re: [Findutils-patches] [PATCH] This change adds a sleep between invocat


From: Eric Blake
Subject: Re: [Findutils-patches] [PATCH] This change adds a sleep between invocations of cmd.
Date: Tue, 20 Sep 2011 13:05:53 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.22) Gecko/20110906 Fedora/3.1.14-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.14

On 09/20/2011 12:33 PM, ed wrote:
Gave that a go today on a vanilla xargs and it doesn't seem to work:

   $ perl -e 'for(my $a=0;$a<100;$a++){print $a,"\n";}' | xargs -l2 sh -c
   'sleep 1&&exec /bin/echo "$@"'
   1
   3
   5
   ^C

For whatever reason the shell seems to throw the first argument away.

The first argument becomes $0 to the shell, so you need to inject a dummy. You meant:

perl -e 'for(my $a=0;$a<100;$a++){print $a,"\n";}' \
 | xargs -l2 sh -c 'sleep 1 && exec /bin/echo "$@"' sh

so that your dummy 'sh' provides the proper $0, and the rest of your arguments are used as you meant.

--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

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