bug-findutils
[Top][All Lists]
Advanced

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

address@hidden: Re: Interaction of the -I and -L options of xargs]


From: James Youngman
Subject: address@hidden: Re: Interaction of the -I and -L options of xargs]
Date: Mon, 20 Jun 2005 12:49:06 +0100
User-agent: Mutt/1.3.28i

The attached email indicates that findutils' current treatment of the
-I and -L options is, I think, correct.  I will update the
documentation to explain the behaviour soon.

James.

--- Begin Message --- Subject: Re: Interaction of the -I and -L options of xargs Date: Mon, 20 Jun 2005 12:17:07 +0100 User-agent: Mutt/1.5.9i
James Youngman <address@hidden> wrote, on 19 Jun 2005:
>
> The functionality of the -L and -I (uppercase i) options by themselves
> is quite clear.  However, how should they work in combination?
> Specifically, what should the output of this be?
> 
>  # Create a file containing the numbers 1 to 10, one per line
>  ( while echo yes ; do true; done ) |sed -n -e '=' -e '10 q' > short-file.txt
>  
>  # This is the test of interest
>  xargs -L 5 -I Z echo foo Z bar < short-file.txt

I think a formal interpretation would have to say that the standard
is unclear and no conformance distinction can be made.

> Should xargs produce (my indentation)
> 
>  foo 1 bar
>  foo 2 bar
>  foo 3 bar
>  foo 4 bar
>  foo 5 bar
>  foo 6 bar
>  foo 7 bar
>  foo 8 bar
>  foo 9 bar
>  foo 10 bar
> 
> or should it produce 
> 
>  foo 1 2 3 4 5 bar
>  foo 6 7 8 9 10 bar
> 
> ... or, should this depend on the order in which -L and -I are
> specified on the command line (ugh)?

You say "ugh", but that is exactly how the standard specifies that
the conflict between -L and -n is handled ("The -L and -n options are
mutually-exclusive; the last one specified shall take effect.").

> IRIX and GNU findutils (as at version 4.2.23) produce the former while
> *BSD produces the latter.  I'm at home today so don't have any other
> systems handy for testing.  

Solaris, HP-UX and Unixware all produce the former.  However, if
you switch the order (i.e. xargs -I Z -L 5 echo foo Z bar) they
all produce:

    foo Z bar 1 2 3 4 5
    foo Z bar 6 7 8 9 10

as does GNU findutils (4.2.21).  I.e. the -L causes the earlier -I
to be ignored.

So it is looking like the appropriate way to handle this in the
next revision would be to have -L and -I cancel each other out, the
same as -L and -n do.  Actually, all three conflict with each other,
so the standard should probably say "The -I, -L and -n options are
all mutually-exclusive; the last one specified shall take effect."

-- 
Geoff Clare <address@hidden>
The Open Group, Thames Tower, Station Road, Reading, RG1 1LX, England


--- End Message ---

reply via email to

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