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   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Reply via email to