xargs doesn't support replacements that would make a string longer than 255 characters

Originator:keithbsmiley
Number:rdar://39429970 Date Originated:13-Apr-2018 18:06
Status:Open Resolved:
Product:Developer Tools Product Version:macOS 10.13.4
Classification:UI/Usability Reproducible:Always
 
Summary:
xargs will not replace the `-I` argument with the string it's operating on if the resulting string would be over 255 characters.

Steps to Reproduce:
Run this command:

```
echo "thisisaveryveryveryverylongstring" | /usr/bin/xargs -I % sh -c 'echo % && echo % && echo % && echo % && echo % && echo % && echo % && echo % && echo % && echo % && echo %'
```

Expected Results:
`thisisaveryveryveryverylongstring` should get echoed 11 times. 

Actual Results:
Instead it is only echoed 4 times, and the others are percent signs:

```
thisisaveryveryveryverylongstring
thisisaveryveryveryverylongstring
thisisaveryveryveryverylongstring
thisisaveryveryveryverylongstring
%
%
%
%
%
%
%
```


Version:
macOS 10.13.4

Notes:
If you pass the `-t` argument to xargs you can see it is running this command:

```
sh -c echo thisisaveryveryveryverylongstring && echo thisisaveryveryveryverylongstring && echo thisisaveryveryveryverylongstring && echo thisisaveryveryveryverylongstring && echo % && echo % && echo % && echo % && echo % && echo % && echo %
```

If you look at xargs.c for 10.13.3 here: https://opensource.apple.com/source/shell_cmds/shell_cmds-203/xargs/xargs.c.auto.html

You can see on line 507 the string size is hard coded to 255.

This is not a bug with xargs from findutils.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!