Bug 264846 - xargs should terminate if line replacement cannot be constructed
Summary: xargs should terminate if line replacement cannot be constructed
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Port Management Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-23 12:13 UTC by Tom Jones
Modified: 2022-06-25 12:52 UTC (History)
1 user (show)

See Also:
thj: exp-run?


Attachments
cause xargs to error if line cannot be constructed (2.16 KB, patch)
2022-06-23 12:13 UTC, Tom Jones
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Jones freebsd_committer 2022-06-23 12:13:59 UTC
Created attachment 234885 [details]
cause xargs to error if line cannot be constructed

https://reviews.freebsd.org/D35574

If the line with replacement cannot be constructed xargs should terminate as
documented in the man page:

-I replstr                                                               
        Execute utility for each input line, replacing one or more       
        occurrences of replstr in up to replacements (or 5 if no -R flag 
        is specified) arguments to utility with the entire line of input.
        The resulting arguments, after replacement is done, will not be  
        allowed to grow beyond replsize (or 255 if no -S flag is         
        specified) bytes; this is implemented by concatenating as much of
        the argument containing replstr as possible, to the constructed  
        arguments to utility, up to replsize bytes.  The size limit does 
        not apply to arguments to utility which do not contain replstr,  
        and furthermore, no replacement will be done on utility itself.  
        Implies -x.

Currently, xargs continues and lines that cannot accommodate the replacement get
as much of the replstr as will fit in the string. Instead xargs should error,
include an error when we do.

We encounter this error, but gnu/xargs doesn't because they have a much larger
limit for created outputs (~10000 lines).